opengl 旋转圆的切线
我现在有一个物体,我正在围绕垂直(Y)轴移动一个圆圈。我想旋转该对象,使其始终与圆的切线对齐,我该怎么做?不确定使用什么 sin/cosine/tan 组合作为 glRotatef 的第一个参数...
谢谢!
I have an object right now which I have moving in a circle around the vertical (Y) axis. I want to rotate this object so it is always aligned with the tangent of the circle, how do I do this? Not sure what combination of sin/cosine/tan to use as the first argument of glRotatef...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
glRotatef 的第一个参数是角度,以弧度为单位(因此 0 表示不旋转,PI 围绕一端翻转,2*PI 一直旋转回原始方向)。
您可能可以通过反复试验自己回答这个问题,所用的时间比提出问题所用的时间要短。
请注意,如果您选择旋转中心作为圆心而不是对象的中心,则不需要单独的平移步骤。
The first argument of
glRotatef
is the angle, in radians (so 0 is no rotation, PI is flipped around end for end, and 2*PI is rotated all the way back to the original orientation).You probably could have answered this yourself through trial and error in less time than it took to askk the question.
Note that if you choose the center of rotation to be the center of the circle instead of the center of the object, you won't need a separate translation step.