[英]3D rotation in OpenGL
So I'm trying to do some rotation operations on an image in openGL based on quaternion information, and I'm wondering, is there a way to define the location of my image by a vector (let's say (001)), and then apply the quaternion to that vector to rotate my image around an arbitrary origin? 因此,我试图基于四元数信息对openGL中的图像进行一些旋转操作,我想知道是否有一种方法可以通过矢量(比如(001))来定义图像的位置,然后将四元数应用于该矢量以围绕任意原点旋转我的图像? I've been using GLM for all the math work. 我一直在使用GLM进行所有数学运算。 (Using C++) (使用C ++)
Or is there a better way to do this that I haven't figured out yet? 还是有一个我还没有想到的更好的方法呢?
如果要围绕点P = {x, y, z}
旋转,则可以简单地按-P
平移,围绕原点旋转,然后按P
向后平移。
The order in which the transforms should be applied are: 应用转换的顺序为:
scale -> translation to point of rotation -> rotation -> translation
So your final matrix should be computed: 因此,应计算最终矩阵:
glm::mat4 finalTransform = translationMat * rotationMat * translationToPointOfRotationMat * scaleMat;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.