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

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

问题描述

我正在寻找一种将方向矢量(X,Y,Z)转换为欧拉角(标题,音高,银行)的方法。我知道方向矢量本身不足以得到倾斜角度,所以还有另一个所谓的上矢量。

具有方向矢量(X,Y,Z )和向量(X,Y,Z)如何将其转换为欧拉角?

解决方案

让我们看看我是否理解正确。这是关于三维空间中刚体的方向,如飞行期间的飞机。这架飞机的鼻子指向方向矢量

  D =(XD,YD,ZD) 。 

朝向顶部是向上

  U =(XU,YU,ZU)。 

然后标题 H 将是投射到地球表面的方向矢量 D

  H =(XD,YD,0),

与相关角度

  angle_H = atan2(YD,XD)。 

P是鼻子的上下角度如果方向向量 D 被标准化,你可以从

  ZD = sin(angle_P)

导致

  angle_P = asin(ZD)。 

最后,对于倾斜角度,我们考虑机翼的方向,假设机翼垂直于身体。如果飞机直接飞向 D ,机翼指向垂直于 D 并平行于地球表面:

  W0 =(-YD,XD,0)

这将是一个0的银行角度。预期上行向量将垂直于 W0 并垂直于 D

  U0 = W0×D 

×表示交叉乘积。 U 等于 U0 如果存储区角度为零,否则 U U0 是银行角度 angle_B ,可以从
$ b $ pre $ cos $(角度_B)=点(U0,U)/ abs(U0)/ abs(U)
sin(angle_B)=点(W0 ,U)/ abs(W0)/ abs(U)。

从这里你得到的银行角度为



< (点(W0,U)/点(U0,U)/ abs(W0)* abs(U0))。

如果 U D 被标准化。


I'm looking for a way to convert direction vector (X,Y,Z) into Euler angles (heading, pitch, bank). I know that direction vector by itself is not enough to get the bank angle, so there's also another so-called Up vector.

Having direction vector (X,Y,Z) and up vector (X,Y,Z) how do I convert that into Euler angles?

解决方案

Let's see if I understand correctly. This is about the orientation of a rigid body in three dimensional space, like an air plane during flight. The nose of that airplane points towards the direction vector

D=(XD,YD,ZD) .

Towards the roof is the up vector

U=(XU,YU,ZU) .

Then heading H would be the direction vector D projected onto the earth surface:

H=(XD,YD,0) ,

with an associated angle

angle_H=atan2(YD,XD) .

Pitch P would be the up/down angle of the nose with respect to the horizon, if the direction vector D is normalized you get it from

ZD=sin(angle_P)

resulting in

angle_P=asin(ZD) .

Finally, for the bank angle we consider the direction of the wings, assuming the wings are perpendicular to the body. If the plane flies straight towards D, the wings point perpendicular to D and parallel to the earth surface:

W0 = ( -YD, XD, 0 )

This would be a bank angle of 0. The expected Up Vector would be perpendicular to W0 and perpendicular to D

U0 = W0 × D

with × denoting the cross product. U equals U0 if the bank angle is zero, otherwise the angle between U and U0 is the bank angle angle_B, which can be calculated from

cos(angle_B) = Dot(U0,U) / abs(U0) / abs(U)
sin(angle_B) = Dot(W0,U) / abs(W0) / abs(U) .

From that you get the bank angle as

angle_B = atan2( Dot(W0,U) / Dot(U0,U) / abs(W0) * abs(U0) ) .

The normalization factors cancel each other if U and D are normalized.

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

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