绕2轴独立旋转
我正在寻找以下问题的解决方案:
我有一个球移动到屏幕的右上角。也就是说,它向右和向上的速度是相同的。
为了模拟其旋转,它具有沿 X 轴和 Y 轴的角速度 - 它们也相等。
到目前为止效果很好。我现在的问题是如何正确旋转显示的球:我正在使用 OpenGL 和一个简单的球体作为球。
现在我天真的方法是使用
glRotate(rx, 1, 0, 0); // rotate about x axis
glRotate(ry, 0, 1, 0); // rotate about y axis
但这并不像我预期的那样工作:第二个轮换取决于第一个轮换。再想一想,这就像我习惯的那样。但现在我正在寻找一种解决方案,通过独立应用两个旋转来正确旋转我的球。
我也尝试使用四元数但没有成功。我什至不确定我是否得到了完全错误的东西,我的方法“绕 x 旋转一些度,然后绕 y 旋转一些度”是否有意义。
任何“启示”都将受到高度赞赏。
谢谢你!
I am looking for a solution to the following problem:
I have a ball travelling to the upper right corner of the screen. That is, its velocity to the right and up are identical.
To simulate its rotation, it has an angular velocity along the X and the Y axis - those are also both equal.
This works fine so far. My problem is now to correctly rotate the ball on display: I am using OpenGL and a simple sphere for the ball.
Now my naive approach was to use
glRotate(rx, 1, 0, 0); // rotate about x axis
glRotate(ry, 0, 1, 0); // rotate about y axis
But this does not work as I intended: The second rotation depends on the first one. On second thought, this works as I was used to it. But now I am looking for a solution to rotate my ball correctly by applying both rotations independently.
I also tried using quaternions but did not succeed. I am even not sure if I get something completely wrong an my approach of "rotate some degrees about x, then some about y" makes sense at all.
Any "enlightment" is greatly appreciated.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样
glRotate(rr, 1,1,0);
在这种情况下,您围绕任意向量 (1,1,0) 旋转。How about
glRotate(rr, 1,1,0);
in that case you rotate around the arbitrary vector (1,1,0).