Reputation: 60
I have orientation sensor giving me the orientation angles (or quaternion) in the world's coordinate. Now I get the Linear acceleration from TYPE_LINEAR_ACCELERATION, which gives the acceleration in phone's coordinates. Now the question is how I convert the acceleration from phone's coordinates to world coordinates? thanks
Upvotes: 0
Views: 1471
Reputation: 425
First of all you need Rotation matrix not orientation values
If you have orintation angles you can convert them a rotation matrix
Rotation Matrix from Euler Angles
After you get the rotation matrix if you multiply it with the acceleration in the earth coordinate system you will get the acceleration in the phone coordinate system
a_p = acceleration in the phone coordinate system
R = Rotation Matrix
a_e = acceleration in the earth coordinate system
a_p = R * a_e
and inverse of the rotation matrix is equal to its transpose
R^-1 = R^T
a_e = R^T * a_p
it means if you multiply the transpose of rotation matrix with phones reading you will get acceleration in the earth coordinate system
Upvotes: 2