目前在开发中遇到一个问题: 需要获取一个设备移动的角度。
通过设备移动的时候可以获得一组数据:
{"ret":true,"batt":100,"temp":20,"gsensor":1,"x":8,"y":-2,"z":258} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":8,"y":-2,"z":257} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":6,"y":-3,"z":258} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":10,"y":-3,"z":259} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":7,"y":-4,"z":257} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":-245,"y":35,"z":-10} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":-244,"y":34,"z":-11} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":-243,"y":34,"z":-12} {"ret":true,"batt":100,"temp":20,"gsensor":1,"x":-244,"y":35,"z":-10}
其中gsensor
的xyz
三个数据可以通过设备得出。
现在厂商提供给我们了几个公式:
其中,g是重力加速度。
如何使用JS或者PHP来根据获取到的x
,y
,z
三个值来获取θ
和ψ
两个角度值?
或者如何根据公式最后一条来计算ψ
? 使用JS或者PHP该如何实现?
繁花如伊
相关分类