Opengl旋转一点

发布于 2024-12-07 21:04:51 字数 105 浏览 1 评论 0原文

我想在opengl中旋转一个形状,但我想在一点上旋转它。也就是说,我有一个圆柱体,我想旋转它,使它看起来像在底部旋转,并且旋转“大小”增加,直到物体落到地面。我将如何在opengl中进行这种旋转?

I want to rotate a shape in opengl, but I want to rotate it at a point. Namely I have a cylinder and I want to rotate it so it looks like it is spinning at the bottom and the spin 'size' increases until the object falls to the ground. How would I do this kind of rotation in opengl?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萧瑟寒风 2024-12-14 21:04:51
  1. 平移到原点
  2. 旋转
  3. 平移回来

所以,如果你想围绕 (a,b,c) 旋转,你可以在步骤 1 中平移 (-a,-b,-c),在步骤 1 中平移 (a,b,c) 3.

(顺便说一下,不要害怕操作数。在内部,您所做的只是将变换矩阵乘以三倍,但是变换顶点的管道不知道您执行了多少操作,它仍然只使用最后一场使用矩阵进行变换的魔力。)

  1. Translate to the origin
  2. Rotate
  3. Translate back

So, if you want to rotate around (a,b,c), you would translate (-a,-b,-c) in step 1, and (a,b,c) in step 3.

(Don't be afraid of the number of operations, by the way. Internally all you do is multiply the transform matrix three times, but the pipeline that transforms the vertices is agnostic of how many operations you did, it still only uses the one final matrix. The magic of using a matrix for transformation.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文