全球轮换

发布于 2024-11-16 19:42:08 字数 250 浏览 13 评论 0原文

GLScene 中,我们有三个参数(RollAngle、PitchAngle 和 TurnAngle)用于围绕局部方向旋转。在下图中,如何围绕全局方向(橙色轴)旋转立方体?

在此处输入图像描述

in GLScene we have three parameters (RollAngle, PitchAngle and TurnAngle) for rotation around local orientation. in the image below, how can I rotate cube around global orientation (orange axis)?

enter image description here

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

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

发布评论

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

评论(3

半夏半凉 2024-11-23 19:42:08

您需要将轴角度旋转转换为欧拉角。这是一个用代码详细解释此过程的链接:
http://www.euclideanspace.com/maths/geometry/rotations /conversions/angleToEuler/index.htm

来自文章:

yaw   = atan2(y * sin(angle)- x * z * (1 - cos(angle)) 
                , 1 - (y2 + z2 ) * (1 - cos(angle)))   

pitch = asin(x * y * (1 - cos(angle)) + z * sin(angle))   

roll  = atan2(x * sin(angle)-y * z * (1 - cos(angle)) 
             , 1 - (x2 + z2) * (1 - cos(angle)))

编辑:重命名变量以与俯仰、偏航、滚动命名一致 习俗。

You would need to convert the axis angle rotation to Euler angles. Here is a link explaining this process in some detail with code:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToEuler/index.htm

From the article:

yaw   = atan2(y * sin(angle)- x * z * (1 - cos(angle)) 
                , 1 - (y2 + z2 ) * (1 - cos(angle)))   

pitch = asin(x * y * (1 - cos(angle)) + z * sin(angle))   

roll  = atan2(x * sin(angle)-y * z * (1 - cos(angle)) 
             , 1 - (x2 + z2) * (1 - cos(angle)))

EDIT: Renamed the variables to be consistent with the pitch, yaw, roll naming convention.

痴梦一场 2024-11-23 19:42:08

也许您可以使用“DummyCube”对象作为父对象。然后你可以先旋转虚拟立方体内的立方体,然后旋转虚拟立方体。

Maybe you could use "DummyCube" object as a parent. Then you can rotate first the cube inside dummy cube and then the DummyCube.

尸血腥色 2024-11-23 19:42:08

这是一种肮脏的欺骗,但如果对象位于原点 (0,0,0) 并且场景中只有一个对象,您可以围绕对象摆动相机(和光源),而不是旋转对象。

This is a dirty cheat, but if the object is at the origin (0,0,0) and there is only one object in the scene, you could swing the camera (and light source) around the object instead of rotating the object.

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