问题
I am trying to work with 3D rotations but I don't seem to get the idea how the framework does the calculations.
For example I get this data:
yaw -1.010544 pitch 0.508249 roll 1.128918
Then I print the corresponding rotation matrix
- 0.599901 -0.128495 -0.789689
- 0.740043 0.464230 0.486649
- 0.304065 -0.876344 0.373584
After reading the API and the wiki, I am pretty sure there must be a general way to create a rotationmatrix out of euler angles. I tried all of these here, no results.
Do I miss something, or how is this done?
回答1:
Well, iOS or CoreMotion provides both. RotationMatrix and Euler Angle Representation. The documentation is here.
But if you are interested how this calculation works, the take a look here. To sum it up: Each Euler Angle can be represented by a rotation matrix which describes a rotation around one unit axis. Since there are three angles, you just have to combine them. But watch out! Euler angles are not unambiguous since there are different orders in which the rotation matrices can be multiplied.
EDIT: You linked to a quaternion calculation. Or am I completely wrong?
来源:https://stackoverflow.com/questions/10010579/explanation-of-ios-rotation-matrix