SCNNode使用SCNVector4进行旋转,该旋转具有一个角度(w)和一个大小,该角度如何应用于每个轴(x,y,z).例如,要绕x轴旋转45度,我将创建一个SCNVector4,如下所示:
The SCNNode take a rotation using a SCNVector4, which has an angle (w) and a magnitude how that angle applies to each axis (x, y, z). For example, to rotate 45 degrees around the x-axis I'd create a SCNVector4 like this:
SCNVector4Make(1.0f, 0, 0, DEG2RAD(45))我想做的是在所有三个轴上旋转它,例如:x轴旋转45度,y轴旋转15度,z轴旋转-135度.有人知道计算最终SCNVector4的数学方法吗?
What I'd like to do is rotate it across all three axis, for example: 45 degrees on the x-axis, 15 degrees on the y-axis and -135 degress across the z-axis. Does anyone know the math to calculate the final SCNVector4?
推荐答案您需要为每个旋转生成一个SCNVector4,然后将它们相乘.请注意,操作顺序很重要!
You'll need to generate an SCNVector4 for each of the rotations, and then multiply them. Note that the order of operations matters!
www.cprogramming/tutorial/3d/rotationMatrices.html 具有相当好的数学公式.任何处理旋转矩阵的OpenGL参考也值得一看.
www.cprogramming/tutorial/3d/rotationMatrices.html has a pretty good writeup of the math. Any OpenGL reference that deals with rotation matrices is worth a look too.
更多推荐
如何为SCNNode计算多轴SCNVector4旋转?
发布评论