views:

335

answers:

2

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?

Thanx

-isdi-

+1  A: 

To give the rotation of the device as three numbers like that, is actually ambiguous. This kind of thing can get quite confusing. I think this might be the best place to start: http://en.wikipedia.org/wiki/Euler_angles

MatrixFrog
A: 

As long as you're careful you can use angles, though it would probably be way easier to use vectors directly.

You'll almost certainly want to do filtering; a simple low-pass would be great, but don't filter out gravity, as it is the orientation of the device :).

Andrew Pouliot