如何将欧拉角转换为方向矢量? [英] How to convert Euler angles to directional vector?

查看:4630
本文介绍了如何将欧拉角转换为方向矢量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有俯仰,滚转和偏航角度。我将如何将这些转换为方向向量?

I have pitch, roll, and yaw angles. How would I convert these to a directional vector?

如果你能显示一个四元数和/或矩阵表示这将是特别酷!

It'd be especially cool if you can show me a quaternion and/or matrix representation of this!

推荐答案

不幸的是,有关如何定义这些东西有不同的约定(滚动,俯仰,偏航不像Euler

Unfortunately there are different conventions on how to define these things (and roll, pitch, yaw are not quite the same as Euler angles), so you'll have to be careful.

如果我们将pitch = 0定义为水平(z = 0),偏航从x轴逆时针定义,则方向向量将为

If we define pitch=0 as horizontal (z=0) and yaw as counter-clockwise from the x axis, then the direction vector will be


x = cos(yaw)*cos(pitch)
y = sin(yaw)*cos(pitch)
z = sin(pitch)

注意,我没有使用roll;这是方向单位向量,它不指定态度。这很容易写一个旋转矩阵,将物体携带到飞行物体的框架(如果你想知道,例如,左翼尖指向),但它是一个好主意,首先指定约定。你能告诉我们更多关于这个问题吗?

Note that I haven't used roll; this is direction unit vector, it doesn't specify attitude. It's easy enough to write a rotation matrix that will carry things into the frame of the flying object (if you want to know, say, where the left wing-tip is pointing), but it's really a good idea to specify the conventions first. Can you tell us more about the problem?

编辑:
(我一直想回到这个问题两年半。)

(I've been meaning to get back to this question for two and a half years.)

对于全旋转矩阵,如果我们使用上面的约定,我们想要矢量先偏航,然后俯仰,滚动为了得到世界坐标系中的最终坐标,我们必须以相反的顺序应用旋转矩阵。

For the full rotation matrix, if we use the convention above and we want the vector to yaw first, then pitch, then roll, in order to get the final coordinates in the world coordinate frame we must apply the rotation matrices in the reverse order.

第一卷:

| 1    0          0      |
| 0 cos(roll) -sin(roll) |
| 0 sin(roll)  cos(roll) |

then pitch:

then pitch:

| cos(pitch) 0 -sin(pitch) |
|     0      1      0      |
| sin(pitch) 0  cos(pitch) |

然后yaw:

| cos(yaw) -sin(yaw) 0 |
| sin(yaw)  cos(yaw) 0 |
|    0         0     1 |

组合它们,总旋转矩阵为:

Combine them, and the total rotation matrix is:

| cos(yaw)cos(pitch) -cos(yaw)sin(pitch)sin(roll)-sin(yaw)cos(roll) -cos(yaw)sin(pitch)cos(roll)+sin(yaw)sin(roll)|
| sin(yaw)cos(pitch) -sin(yaw)sin(pitch)sin(roll)+cos(yaw)cos(roll) -sin(yaw)sin(pitch)cos(roll)-cos(yaw)sin(roll)|
| sin(pitch)          cos(pitch)sin(roll)                            cos(pitch)sin(roll)|

所以对于从x轴开始的单位向量,最终坐标为:

So for a unit vector that starts at the x axis, the final coordinates will be:

x = cos(yaw)cos(pitch)
y = sin(yaw)cos(pitch)
z = sin(pitch)

对于从y轴(左翼尖) ,最终坐标将是:

And for the unit vector that starts at the y axis (the left wing-tip), the final coordinates will be:

x = -cos(yaw)sin(pitch)sin(roll)-sin(yaw)cos(roll)
y = -sin(yaw)sin(pitch)sin(roll)+cos(yaw)cos(roll)
z =  cos(pitch)sin(roll)

这篇关于如何将欧拉角转换为方向矢量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆