四元数和旋转
GLM - Quaternions and Rotation
我试图使用四元数,以便在我的程序中旋转对象。
但是他们的问题是……一个旋转。我试着这样旋转矩阵:
ModelMatrix = ModelMatrix * glm::toMat4(glm::quat(RotationW, RotationX, RotationY, RotationZ));
与随机数,结果是一个巨大的缩放(为什么)和一点点旋转。
另外我们有:
quat3 = quat2 * quat1
Model1 = Model * glm::toMat4(glm::quat( quat3.w , quat3.x, quat3.y, quat3.z);
Model2 = Model * glm::toMat4(glm::quat( quat1.w , quat1.x, quat1.y, quat1.z);
Model2 = Model2 * glm::toMat4(glm::quat( quat2.w , quat2.x, quat2.y, quat2.z);
Model2和Model1是否具有相同的旋转?
我知道glm::rotate(Model,RotationAngle, RotationAxis),但我宁愿使用四元数
为了使四元数表示纯旋转,它必须是单位四元数。随机数通常没有这个属性。您可能希望在生成四元数之前对它们进行规范化:
l = sqrt(RotationW * RotationW + RotationX * RotationX
+ RotationY * RotationY + RotationZ * RotationZ);
RotationW /= l;
RotationX /= l;
...
当然,仅仅将四元数转换为矩阵是没有意义的。直接计算矩阵会更有效率。
对于四元数乘积,您的顺序错了:
q3 = q2 * q1
=> M * mat(q3) = M * mat(q2) * mat(q1)
相关文章:
- 将四元数旋转的游戏对象旋转另一个四元数时出现问题
- 在OpenGL(GLM/C++)中使用四元数旋转时出现问题
- 四元数旋转不起作用
- 使用四元数防止绕某个轴旋转
- 如何使用四元数来描述超过360度的旋转角度?
- 四元数旋转错误
- 特征:将矩阵3d旋转转换为四元数
- 用四元数绕轴旋转矢量
- 四元数 -> 欧拉角 -> 旋转矩阵问题 (GLM)
- C++OpenGl相机旋转使用四元数问题
- 将 glm 四元数转换为旋转矩阵并将其与 opengl 一起使用
- 四元数旋转是我瞎了还是只是做错了
- 如何否定GLM四元数在任何单轴上的旋转
- 使用四元数旋转摄影机
- 特征c++ / Matlab四元数与旋转矩阵不匹配
- 如何缩放四元数的旋转
- GLM矩阵的旋转方向,使用四元数
- 提高QVM旋转与四元数
- 小四元数相机bug?(在Z轴上轻微旋转)
- 四元数旋转不太对