Phonegap Accelerometer y value to degrees

蹲街弑〆低调 提交于 2019-12-22 17:49:03

问题


Phonegap accelerometer seems to return y values as below:

// +10 y axis = straight up = 0/360 deg
// -10 y axis = straight down = 180 deg
// flat y axis = 90/270 deg

My question is, how do I convert this y axis to the given degrees?

Also, as it's phonegap, I'm assuming these values are the same for all devices. if anyone knows otherwise please let me know.


回答1:


Try this:

deg = acceleration.y / 10 * 90; 

I think that worked for me when I was doing something similar.



来源:https://stackoverflow.com/questions/10758043/phonegap-accelerometer-y-value-to-degrees

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!