内旋下,xyz 顺序的旋转矩阵转欧拉角的公式如下:
yaw = atan2(R(1, 0), R(0, 0)) pitch = asin(-R(2, 0)) roll = atan2(R(2, 1), R(2, 2))
其中 R 是旋转矩阵,yaw、pitch、roll 分别对应欧拉角的 yaw、pitch、roll 轴。
代码示例如下:
import math
def rotation_matrix_to_euler_angles(R):
yaw = math.atan2(R[1, 0], R[0, 0])
pitch = math.asin(-R[2, 0])
roll = math.atan2(R[2, 1], R[2, 2])
return yaw, pitch, roll