如何为SCNNode计算多轴SCNVector4旋转? [英] How can I calculate a multi-axis SCNVector4 rotation for a SCNNode?

查看:632
本文介绍了如何为SCNNode计算多轴SCNVector4旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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!

http://www.cprogramming.com/tutorial/3d/rotationMatrices.html 具有相当好的数学公式.任何处理旋转矩阵的OpenGL参考也值得一看.

http://www.cprogramming.com/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旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆