iPhone方向表示为旋转

时间:2009-06-18 03:43:37

标签: iphone orientation accelerometer

Ola Folks,

 This might not be the right place for this. Let me know where I should post if I should post it elsewhere.

 I want to get the orientation of the device. I am thinking I can use something like this:

float fAngleX = atan2(acceleration.y, acceleration.z);
float fAngleY = atan2(acceleration.x, acceleration.z);
float fAngleZ = atan2(acceleration.y, acceleration.x);


 First, is my formula right?
 Second, is this going to work for the device? 
 Third, I'm going back and forth about filtering out gravity. Any thoughts?
 Lastly, is there a better way to get the devices orientation expressed as rotation for all three axis?

感谢名单

-isdi -

2 个答案:

答案 0 :(得分:1)

要将设备旋转为三个这样的数字,实际上是模棱两可的。这种事情会让人很困惑。我认为这可能是最好的开始:http://en.wikipedia.org/wiki/Euler_angles

答案 1 :(得分:0)

只要你小心你可以使用角度,虽然它可能更容易直接使用矢量。

你几乎肯定想做过滤;一个简单的低通很好,但不要过滤掉重力,因为设备的方向:)。