Axes Transformations 坐标转换

今天闲来无事想起来以前在MATLAB中进行坐标变换都自己编写了坐标转换函数,MATLAB中应该会有吧,找了下帮助果真有,其实在MATLAB的AerospaceToolBox中封装好了很多坐标转换函数,可以直接调用完成对坐标系相对关系的描述。

angle2dcm

Create direction cosine matrix from rotation angles

由旋转角度创建方向余弦矩阵

Syntax

dcm =

angle2dcm(rotationAng1,

rotationAng2, rotationAng3)

dcm = angle2dcm(rotationAng1,

rotationAng2, rotationAng3,

rotationSequence)

Description

dcm =

angle2dcm(rotationAng1,

rotationAng2, rotationAng3)

calculates the direction cosine matrix given three sets of rotation

angles. 由三个旋转角计算方向余弦矩阵

dcm =

angle2dcm(rotationAng1,

rotationAng2, rotationAng3,

rotationSequence) calculates the direction

cosine matrix using a rotation sequence.由特定的旋转序列计算方向余弦矩阵

这里的旋转角是指右手系下的旋转方向为正如图

a4c26d1e5885305701be709a3d33442f.png

而得出的方向余弦矩阵dcm 是由原坐标系经旋转后到新坐标系的转换矩阵。

例如在导航专业中用到的导航坐标系到载体坐标系的旋转就可以用此函数求的,而求的的方向余弦矩阵为导航坐标系转向载体坐标系的,即Cnb

Inputs

rotationAng1

m-by-1 array of first rotation angles, in

radians. 第一个旋转角

rotationAng2

m-by-1 array of second rotation angles, in

radians. 第二个旋转角

rotationAng3

m-by-1 array of third rotation angles, in

radians.第三个旋转角

rotationSequence

String that defines rotation sequence. For example, the default

'ZYX' represents a sequence where

rotationAng1 is z-axis

rotation, rotationAng2 is

y-axis rotation, and

rotationAng3 is x-axis

rotation.

定义旋转序列的字符串。例如默认的'ZYX'表示了一个这样的旋转顺序:rotationAng1是绕Z轴旋转,rotationAng2

是绕y轴旋转,rotationAng3绕x轴旋转。共有如下几种形式:

'ZYX'

'ZYZ'

'ZXY'

'ZXZ'

'YXZ'

'YXY'

'YZX'

'YZY'

'XYZ'

'XZY'

'XYX'

'XZX'

'ZYX' (default)

Outputs

dcm

3-by-3-by-m matrix containing m

direction cosine matrices.

3X3的方向余弦矩阵

Examples

将原坐标系axis1先沿着z轴旋转20度,沿着x轴旋转30度,再沿着y轴旋转45度,得到新的坐标系axis2。

那么在坐标系axis1中的点A(2,3,4)在新的坐标系axis2中的坐标B用以下方法来求得:

A=[2;3;4];

dcm=angle2dcm(20*pi/180,30*pi/180,45*pi/180,'ZXY');

B=dcm*A

>> B

=

0.359820367873134

3.848996778596074

3.749100305569416

即B坐标为(0.359820367873134,3.848996778596074,3.749100305569416)

在这里,方向余弦矩阵有个性质,即:方向余弦矩阵是正交的,就是其逆等于其转置 dcm'=inv(dcm);

所以如果需要坐标反向转换,只需要这样用:

dcm_inv=dcm';

C=dcm_inv*B;

>> C =

2.000000000000000

3.000000000000000

4.000000000000000

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐