使用 QQuaternion 类旋转对象

发布于 2025-01-12 13:08:23 字数 531 浏览 1 评论 0原文

我一直在尝试使用 QQuaternion 类的函数来旋转对象。

我定义了我的四元数然后将其标准化。现在我正在努力使用这个特定的函数使其旋转:

void QMatrix4x4::rotate(const QQuaternion &quaternion)

所以这个函数将当前矩阵(这个矩阵)与对应于我定义的四元数的旋转矩阵相乘。在我的代码中,当前矩阵是模型视图矩阵。

所以从逻辑上讲,我应该输入 m.rotate(quaternion) 但如何指定 m 实际上是模型视图矩阵?

这就是我试图做的:

   GLfloat matrix[16];
   glGetFloatv (GL_MODELVIEW_MATRIX, matrix);
   matrix.rotate(quaternion);

我想现在函数知道矩阵实际上是模型视图矩阵。 但是,我收到一个错误:成员引用基类型 GLfloat [16] 不是结构或联合。所以我认为这不是正确的做法。

I've been trying to rotate an object using the functions of the class QQuaternion.

I defined my quaternion then normalize it. Now I'm struggling to make it rotate using this specific function :

void QMatrix4x4::rotate(const QQuaternion &quaternion)

So this function multiplies a current matrix (this matrix) with the rotation matrix that corresponds to the quaternion I defined. In my code, the current matrix is the modelview matrix.

So logically, I should type m.rotate(quaternion) but how can I specify that m is actually the modelview matrix ?

here is what I tried to do:

   GLfloat matrix[16];
   glGetFloatv (GL_MODELVIEW_MATRIX, matrix);
   matrix.rotate(quaternion);

I think now the function knows that matrix is actually the modelview matrix.
But, I got an error: member reference base type GLfloat [16] is not a structure or union. So I don't think it's the right way to do it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文