计算坐标系的欧拉角

最近学到了"pitch,Roll,Yaw"几个专业术语,简单来说就是坐标系的绕轴旋转。

在几何测量里,坐标系作为测量基础,是重点关注对象。不同的坐标系会导致不同的测量的数值。坐标系通过旋转和平移进行转换:

RA+t=B

绕X旋转

A_x= \begin{bmatrix} 1&0&0\\ 0&cos(\theta)&sin(\theta)\\ 0&-sin(\theta)&cos(\theta)\\ \end{bmatrix}

绕Y旋转

A_y= \begin{bmatrix} cos(\theta)&0&-sin(\theta)\\ 0&1&0\\ sin(\theta)&0&cos(\theta) \\ \end{bmatrix}

绕Z旋转

A_z= \begin{bmatrix} cos(\theta)&sin(\theta)&0\\ -sin(\theta)&cos(\theta)&0\\ 0&0&1 \\ \end{bmatrix}

计算上面的角度就可以了。
在CALYPSO中建立两个坐标系“base”和“Alignment4”

还是一样通过PCM把坐标系差异写出

writeDiffCoordSysToFile("Alignment4","base","C:\temp\diff1.txt")

在下面程序里计算

import numpy as np

def get_transformation(filename):
    diff = np.genfromtxt(filename)
    r = diff[:9].reshape((3,3))
   # t = diff[9:].reshape((3,1))
    # print(r)
    # print(t)
    return r


rotate_matrix = get_transformation('diff1.txt')


RM = np.array(rotate_matrix)




# 旋转矩阵到欧拉角
def rotateMatrixToEulerAngles2(R):
    theta_z = np.arctan2(RM[1, 0], RM[0, 0]) / np.pi * 180
    theta_y = np.arctan2(-1 * RM[2, 0], np.sqrt(RM[2, 1] * RM[2, 1] + RM[2, 2] * RM[2, 2])) / np.pi * 180
    theta_x = np.arctan2(RM[2, 1], RM[2, 2]) / np.pi * 180
    print(f"Euler angles:\ntheta_x: {theta_x}\ntheta_y: {theta_y}\ntheta_z: {theta_z}")
    return theta_x, theta_y, theta_z



if __name__ == '__main__':
    rotateMatrixToEulerAngles2(RM)

得出结果:

Euler angles:
theta_x: 0.3315200000001608
theta_y: 0.22513000000007857
theta_z: 5.111249999999829
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值