## Introduction

A unit quaternion, known as a versor, provides a convenient mathematical notation for representing the spatial orientation and rotation of an element in three-dimensional space. Specifically, it encodes information about an axis-angle rotation about an arbitrary axis. Rotation and orientation quaternions have applications in computer graphics, computer vision, robotics, navigation, molecular mechanics, flight mechanics, satellite orbital mechanics, and crystallography. When used to represent rotation, the unit quaternion is also called the rotation quaternion. 3D rotation group. When used to represent orientation (rotation about a reference frame), they are called orientation quaternions or pose quaternions. Spatial rotation around a fixed point θ {\displaystyle \theta } radians around unit axis ( X , Y , Z. ) {\displaystyle (X,Y,Z)} Denoting the Euler axis is given by the quaternion ( C. , X S. , Y S. , Z. S. ) {\displaystyle (C,X\,S,Y\,S,Z\,S)} , where C. = cos ⁡ ( θ / 2 ) {\displaystyle C=\cos(\theta /2)} and S. = sin ⁡ ( θ / 2 ) {\displaystyle S=\sin(\theta /2)} . Compared to rotation matrices, quaternions are more compact, efficient, and numerically stable. Easier to construct than Euler angles. However, these are not intuitive and easy to understand, and due to the periodic nature of the sine and cosine, rotation angles that differ exactly by natural period are encoded into the same quaternion, and the recovered angle in radians is It is limited as follows. [ 0 , 2 Pi ] {\displaystyle [0,2\pi ]} .

## = The composition of spatial rotations =

The advantage of formulating the composition of two rotations RB and RA in quaternions is that the rotation axis and angle of the composite rotation RC = RBRA are directly available. Suppose we want to construct a quaternion associated with a spatial rotation R using rotation angles from its rotation axis S. φ {\displaystyle \varphi} centered around this axis. The relevant quaternions are given by: In this case, the composition of the rotations RB and RA is the rotation RC = RBRA where the rotation axis and angle are defined by the product of the quaternions. That is Deploying this product Divide both sides of this equation by the identity. This is the cosine law on the sphere. and calculate This is Rodriguez's formula for the axis of compound rotation defined in terms of two axes of rotation. He derived this formula in his 1840 (see page 408). The three axes of rotation A, B, and C form a spherical triangle, and the dihedral angle between the planes formed by the sides of this triangle is defined by the rotation angle. Hamilton presents a component form of these equations in which the quaternion product computes his third vertex of a spherical triangle from his two vertices and their associated arc lengths given, which in elliptic geometry is We showed that we also define the algebra of points.

## == Axis–angle composition ==

normalized axis of rotation, cos ⁡ γ 2 {\textstyle \cos {\frac {\gamma }{2}}} The expanded product leaves a vector that is the axis of rotation multiplied by some constant. Be careful with normalizing the axis vectors. γ {\displaystyle \gamma } teeth 0 {\displaystyle 0} or k 2 Pi {\displaystyle k2\pi } where the vector is near 0 {\displaystyle 0} ; which means identity, i.e. 0 rotation about any axis. Or use the angle addition trigonometric permutation... Finally, normalize the rotation axis. D. 2 sin ⁡ 1 2 γ {\textstyle {\frac {\mathbf {D} }{2\sin {\frac {1}{2}}\gamma }}} or D. ‖ D. ‖ {\textstyle {\frac {\mathbf {D} }{\|\mathbf {D} \|}}} .

## Quaternion rotation operations

A very formal description of the properties used in this section is provided by Altman.

## == Parameterizing the space of rotations ==

You can parameterize the surface of a sphere using two coordinates, such as latitude and longitude. However, while the north and south poles are not inherently different from any other point on the sphere, latitude and longitude malfunction (degenerate) at the north and south poles. At the poles (latitude +90° and -90°) the longitude becomes meaningless. It turns out that a two-parameter coordinate system cannot avoid such degeneracy. Such a problem is to embed a sphere in 3-dimensional space, parameterize it with three Cartesian coordinates (w, x, y), and place the north pole at (w, x, y) = (1, 0, 0). can be avoided by The south pole is at (w, x, y) = (−1, 0, 0), the equator is at w = 0, x2 + y2 = 1. A point on the sphere satisfies the constraint w2 + x2 + y2 = 1. So even though we have three coordinates, we still only have two degrees of freedom. A point (w, x, y) on the sphere represents a rotation in normal space about the horizontal axis by the angle specified by the vector (x, y, 0). α = 2 cos − 1 ⁡ w = 2 sin − 1 ⁡ X 2 + y 2 {\displaystyle \alpha =2\cos ^{-1}w=2\sin ^{-1}{\sqrt {x^{2}+y^{2}}}} . Similarly, the hypersphere space of the 3D rotation can be parameterized by three angles (Eulerian angles), but such a parameterization is degenerate at some points on the hypersphere, causing gimbal lock problems. This can be avoided by using four Euclidean coordinates w, x, y, z (w2 + x2 + y2 + z2 = 1). The point (w, x, y, z) is the vector (x, y, z) by angle α = 2 cos − 1 ⁡ w = 2 sin − 1 ⁡ X 2 + y 2 + z 2 . {\displaystyle \alpha =2\cos ^{-1}w=2\sin ^{-1}{\sqrt {x^{2}+y^{2}+z^{2}}}.}

## = Non-commutativity =

Quaternion multiplication is noncommutative. This fact explains how the formula for p ↦ q p q−1, where q q−1 = 1 by definition, works. Since unit quaternion multiplication corresponds to composition of 3D rotations, we can intuitively understand this property by showing that 3D rotations are not commutative in general. Place the two books next to each other. Rotate one of them 90 degrees clockwise around the Z axis, then flip it 180 degrees around the X axis. Take the other book and flip it 180 degrees around the x-axis first, then 90 degrees clockwise around the z-axis. These two books of his are not parallel after all. This indicates that, in general, the composition of his two different rotations about two different spatial axes does not commute.

## = Orientation =

The cross product of the vectors used to define the axis and angle expressions gives the orientation (“handedness”) in space. In a three-dimensional vector space, the three vectors in the equation a × b = c are always pointing to the right. Use a -handedness set (left-handedness set, depending on how the cross product is defined) to fix the orientation in vector space. Alternatively, directional dependence is expressed with reference to such. you → {\displaystyle {\vec {u}}} Specifies a rotation about an axis vector. In quaternion form, the choice of spatial orientation corresponds to the order of multiplication: ij = k, but ji = −k. Reversing the direction, the above expression becomes p ↦ q−1 p q. That is, the unit q is replaced by a conjugate quaternion. This is the same behavior as for axis vectors.

## = Software applications by convention used =

The table below groups applications according to their adherence to one of the quaternion rules. The use of either rule has no effect on the functionality or correctness of applications written in this way, but the authors of Schuster's rule deviate from Hamilton's much older quaternion multiplication rule. and should be abandoned as it may never be adopted by any mathematical or theoretical method. physics field.

## = Advantages of quaternions =

Representing the rotation as a quaternion (4 numbers) is more compact than as an orthogonal matrix (9 numbers). Moreover, for a given axis and angle, we can easily construct the corresponding quaternion, and conversely, for a given quaternion, we can easily read the axis and angle. Both of these are much more difficult with matrices and Euler angles. Video games and other applications are often interested in "smooth rotation". This means that the scene rotates slowly instead of in one step. This can be achieved by choosing a curve such as a quaternion spherical linear interpolation. One end point is the identity transformation 1 (or other initial rotation), the other end point is the desired final rotation. This is even more of an issue with other representations of rotation. Composing multiple rotations on a computer inevitably accumulates rounding errors. A slightly off quaternion represents a rotation even after being normalized. Slightly misaligned matrices may no longer be orthogonal and will be difficult to transform back into a properly orthogonal matrix. Quaternions also avoid a phenomenon called gimbal lock, which can occur when pitch is rotated 90° up or down, for example in a pitch/yaw/roll rotation system. As a result, yaw and roll correspond to the same motion, and rotational freedom is lost. For example, in a gimbal-based aerospace inertial navigation system, this can have disastrous consequences if the aircraft is plummeting or climbing.

## == From an orthogonal matrix to a quaternion ==

Some simple methods tend to be unstable if the rotation matrix trace (the sum of the diagonal elements) is zero or very small, so be careful when converting the rotation matrix to a quaternion . See Rotation matrices#Quaternions for a stable way to convert orthogonal matrices to quaternions.

## = Performance comparisons =

This section discusses the performance implications of using quaternions and other methods (axis/angles or rotation matrices) to perform rotations in 3D.

## == Results ==

Rotations are expressed in unit quaternions, so only three of the quaternion components are independent. Further calculations usually require all four elements, so every calculation incurs the additional cost of retrieving his fourth element. Similarly, the angular axis can be stored in a 3-component vector by multiplying the unit direction by the angle (or a function thereof), but using this in the computation incurs additional computational cost. * Quaternions can be implicitly converted to rotation-like matrices (12 multiplications and 12 additions/subtractions). This smoothes the rotation cost of the vector below using the rotation matrix method.

## Pairs of unit quaternions as rotations in 4D space

Karl Groovin (1970). "Derivation of quaternion schemes with Euler axes and angles". Journal of spaceships and rockets. 7(10):1261–1263. Bibcode: 1970JSpRo...7.1261G. Doi: 10.2514/3.30149. Batty Pratt, E.P. Lacy, T.J. (1980). "Geometric model of elementary particles". International Journal of Theoretical Physics. 19(6):437–475. Bibcode: 1980IJTP...19..437B. Doi: 10.1007/BF00671608. S2CID 120642923. Arrivas, M. Elipe, A. Palacios, M. (2006). "Quaternions and Rotations of Rigid Bodies". Celeste. Mecha. Ding. Astron. 96(3-4):239-251. Bibcode: 2006CeMDA..96..239A. Doi: 10.1007/s10569-006-9037-6. S2CID 123591599.

Shoemaker, Ken. "Quaternions" (PDF). Archived (PDF) from the original on May 3, 2020. "Simple quaternion types and operations in over 75 computer languages". About the Rosetta Code Hart, John C. "The Quaternion Demonstrator". Dam, Eike B. Koch, Martin. Lilholm, Martin (1998). "Quaternions, Interpolation, and Animation" (PDF). Leandra, Vic (2001). "Quaternions and Rotations in Three Spaces: Algebras and Their Geometric Interpretations" (PDF). Howell, Thomas. Lafon, Jean-Claude (1975). "The Quaternion Product Complexity, TR75-245" (PDF). Cornell University. Horn, Bertolt K.P. (2001). "Notes on Unit Quaternions and Rotations" (PDF). Byeong-wook Lee (1991) Unit Quaternion Representation of Rotation - Appendix A, Derivatives with Quaternions - Appendix B (PDF) (Doctoral Thesis). Stanford University. Vance, Rod. "Some examples of connected Lie groups". Archived from the original on 2018-12-15. "Visual Representation of Quaternion Rotation".

## Dictionary

### Quaternions

Noun

• the cardinal number that is the sum of three and one