根据滚动,俯仰和偏航值创建CMAttitude旋转矩阵

时间:2013-11-01 22:38:26

标签: iphone matrix rotation core-motion pitch

我正试图从滚动,俯仰和偏航值中获得(Apple风格,CMAttitude)旋转矩阵。有人知道转换是如何运作的吗?

示例:

roll:1.01315, 球场:1.54177和 偏航:-0.361097

应该产生这个旋转矩阵:

enter image description here

谢谢!

1 个答案:

答案 0 :(得分:0)

我认为你可以通过CATransform3D实现这一目标。

你会使用这两个电话:

CATransform3D CATransform3DMakeRotation (CGFloat angle, CGFloat x, CGFloat y, CGFloat z);
CATransform3D CATransform3DRotate (CATransform3D t, CGFloat angle, CGFloat x, CGFloat y, CGFloat z)

你需要弄清楚滚动,俯仰和偏航是如何与坐标系相对应的(通常是x,y,z,但可能是z,x,y)

然后就这样做一个组合:

CATransform3D transform = CATransform3DMakeRotation(anglex, 1.0, 0.0, 0.0);
transform = CATransform3DRotate(transform, angley, 0.0, 1.0, 0.0);
transform = CATransform3DRotate(transform, anglez, 0.0, 0.0, 1.0);

您的转换现在将保留您正在寻找的矩阵。