Recently, I want to use this thing, sort it out, record it, and share it
Based on the content of Matlab's existing functions
Matlab - rotation matrix, quaternion, Euler angle conversion
Rotation matrix dcm R
quaternion quat q = [q0 q1 q2 q3]
Euler angle angle [row,pitch, yaw]/[r1,r2,r3]
Note: The above table is to help understand the expression
roll (roll) --X pitch (pitch) --Y yaw (yaw/heading) -- Z
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - to
quaternion
Rotation Matrix to Quaternion
q =dcm2quat(R);
Euler Angle to Quaternion
q=angle2quat(r1,r2,r3,S);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - to Euler
angles
Rotation Matrix to Euler Angles
[r2,r2,r3]=dcm2angle(R, S)
Note: The obtained result is in radians, and further conversion is required if the angle is required
Quaternion to Euler angle
[r1,r2,r3]=quat2angle([q0 q1 q2 q3],S)
Note: There are 12 options for S, ['ZYX','ZYZ','ZXY','ZXZ','YXZ','YXY','YZX','YZY','XYZ','XYX', 'XZY','XZX']
S defaults to 'ZYX'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - to rotation
matrix
Quaternion to Rotation Matrix
R=quat2dcm([q0 q1 q2 q3])
Euler Angles to Rotation Matrix
R=angle2dcm(r1,r2,r3,S);
R=angle2dcm(yaw/180*pi,pitch/180*pi,roll/180*pi)
Note: According to the Euler angle is radian/angle, choose the above operation
- - - - - - - - - - - - - - - - - - - - - - -- - - -- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If the rotation matrix R is known, find the quaternion [q0 q1 q2 q2]
R=⎡⎣⎢r11r21r31r12r22r32r13r23r33⎤⎦⎥
Then the corresponding quaternion is:
q0=121+r11+r22+r33−−−−−−−−−−−−−√√
q1=r32−r234q0
q2=r13−r314q0
q3=r21−r124q0
- - - - - - - - - - - - - - - - - - - - - - -- - - -- - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Update and improve intermittently.
Share and be patient. hope it helps