English reference link: Quaternions
DCM Tutorial – An Introduction to Orientation Kinematics – Starlino Electronics
https://ntrs.nasa.gov/api/citations/19770024290/downloads/19770024290.pdf
Quaternions, which are a generalization of complex numbers represented by four real numbers, can be used to efficiently represent and compute rotations in three-dimensional space1 .
DCM matrix
DCM matrix is a matrix used to describe the transformation between two coordinate systems. If we record the first coordinate system as x and the second coordinate system as y, then the DCM matrix is a 3x3 matrix, and each column of it is the representation of a unit vector of the y coordinate system in the x coordinate system.
or
and
The DCM matrix (also often referred to as the rotation matrix) defines the rotation of one frame relative to another. It can also be used to determine the coordinates of an arbitrary vector in the global frame if we know the coordinates of the arbitrary vector in the B frame (and vice versa).
a vector with body coordinates:
Quaternion
Properties of rotation quaternions:
- All rotation quaternions must be unit quaternions.|q| = 1
- For rotation quaternions, the inverse equals the conjugate. So for rotation quaternions, q−1 = q* = ( q0, −q1, −q2, −q3 ).
- If a point p is turned into p' after being rotated by q, then it will be changed back to p by rotating p' by q−1 or q*. This is because the two rotations cancel each other out
- A rotation of qa followed by a rotation of qb can be combined into the single rotation qc = qbqa.
Convert quaternion to rotation matrix
Convert rotation matrix to quaternion
Convert Euler Angles to Quaternion
θ (theta) y
φ (phi) x
ψ (psi) z
agreement:
- Intrinsic rotation (axis moves with each rotation)
- Active (aka alibi) rotation (rotates the point, not the coordinate system)
- Right-handed coordinate system with right-handed rotation
The quaternion q corresponding to the Euler angles z, x, and y in ZXY order is:
= np.arcsin(2q2*q3 + 2q0*q1)
=np.arctan2(
2q0q2 - 2q1q3
--------------------
1 - 2q1q1 - 2q2q2
)
= np.arctan2(
2*q0*q3 - 2*q1*q2
---------------------------
1 - 2*q1*q1 - 2*q3* q3
)
The quaternion q corresponding to the Euler angles z, y, and x of the ZYX order is:
The Euler angles z, y, x in ZYX order means first rotate the z angle around the z axis of the fixed coordinate system, then rotate the y angle around the rotated y axis, and finally rotate the x angle around the rotated x axis. The z, y, and x here are all angles relative to the fixed coordinate system, not the angle relative to the rotated coordinate system. That is to say, z is the yaw angle (yaw) in the initial state, y is the pitch angle (pitch) in the initial state, and x is the roll angle (roll) in the initial state.
Convert Quaternion to Euler Angles