% eularAngle_to_rotationMatrix.m
clear all;close all;clear;clc;
%欧拉角
roll = pi/2;
pitch = pi/3;
yaw = pi/4;
angle_xyz = [roll pitch yaw];
angle_zyx = [yaw pitch roll];
%欧拉角转旋转矩阵
rMX = [1 0 0;
0 cos(roll) -sin(roll);
0 sin(roll) cos(roll)];
rMY = [cos(pitch) 0 sin(pitch);
0 1 0;
-sin(pitch) 0 cos(pitch)];
rMZ = [cos(yaw) -sin(yaw) 0;
sin(yaw) cos(yaw) 0;
0 0 1];
rotationMatrix_zyx = rMZ*rMY*rMX;
rotationMatrix_xyz = rMX*rMY*rMZ;
eul2rotm_default=eul2rotm(angle_zyx);
eul2rotm_zyx=eul2rotm(angle_zyx,'ZYX');
eul2rotm_xyz=eul2rotm(angle_xyz,'XYZ');
angle2dcm_default=angle2dcm(yaw, pitch, roll);
angle2dcm_zyx=angle2dcm(yaw, pitch, roll, 'ZYX');
angle2dcm_xyz = angle2dcm(roll, pitch, yaw, 'XYZ');
assert(min(min(rotationMatrix_zyx==eul2rotm_default))==1)
assert(min(min(eul2rotm_default==angle2dcm_default'))==1)
assert(min(min(eul2rotm_default==eul2rotm_zyx))==1)
assert(min(min(rotationMatrix_xyz==eul2rotm_xyz))==1)
assert(min(min(eul2rotm_xyz==angle2dcm_xyz'))==1)
欧拉角转旋转矩阵
最新推荐文章于 2024-05-16 14:57:12 发布