Physics Library
 An open source physics library
Encyclopedia | Forums | Docs | Random | Template Test |  
Login
create new user
Username:
Password:
forget your password?
Main Menu
Sections

Meta

Talkback

Downloads

Information
Axis Angle Representation and Unit Quaternion (Definition)

Axis Angle Representation and Unit Quaternion

A three dimensional rigid body orientation can be described by an axis and an angle. The axis is a unit vector $\widehat{\mathbf u}$ that is unchanged by the corresponding rotation, and the angle $\theta$ specifies the relative rotation of one reference frame with respect to another about that axis. Unit quaternions encode exactly this axis angle information in a compact algebraic form.

For the PhysicsLibrary convention, let frame $B$ be obtained from frame $A$ by a positive right hand rule rotation of the frame axes through angle $\theta$ about the unit axis $\widehat{\mathbf u}$. The passive coordinate map

$\displaystyle {}^{B}\mathbf v = {}^{B}q_A\,{}^{A}\mathbf v\,({}^{B}q_A)^* $

is represented by

$\displaystyle {}^{B}q_A = \cos\frac{\theta}{2} - \widehat{\mathbf u}\sin\frac{\theta}{2}.$ (1)

The negative sign in the vector part is fundamental to the passive convention. It is not a storage convention and does not change Hamilton multiplication. It appears because a positive rotation of the coordinate frame produces the inverse coordinate motion of a fixed physical vector.

The appearance of the half angle is equally fundamental. It follows from the two sided quaternion action on three dimensional vectors.

This entry develops the passive axis angle form, explains the half angle, derives axis and angle recovery, and connects the result to the equivalent active rotor. The next PhysicsLibrary entry develops the full passive coordinate transformation formula and its relation to Rodrigues' formula.

Convention declaration

Unless explicitly stated otherwise, this entry uses Hamilton multiplication,

$\displaystyle \mathbf i\mathbf j=\mathbf k, \qquad \mathbf j\mathbf k=\mathbf i, \qquad \mathbf k\mathbf i=\mathbf j, $

with reversed products changing sign. Physical Cartesian frames are right handed, positive frame rotation follows the right hand screw rule, and quaternion components are displayed scalar first:

$\displaystyle q =q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k \quad\longleftrightarrow\quad \begin{bmatrix} q_w&q_x&q_y&q_z \end{bmatrix}^{T}.$ (2)

The canonical PhysicsLibrary attitude quaternion is

$\displaystyle {}^{B}q_A,$ (3)

which maps coordinates from frame $A$ into frame $B$:

$\displaystyle {}^{B}v = {}^{B}q_A\,{}^{A}v\,({}^{B}q_A)^*.$ (4)

The inverse frame map is

$\displaystyle {}^{A}q_B = ({}^{B}q_A)^*.$ (5)

Scalar first versus scalar last storage is only a component layout choice; it does not change the quaternion multiplication law, frame map direction, or axis angle sign.

For a detailed comparison of convention choices, see Quaternions for Physics and Engineering: Orientation, Notation, and Conventions.

Axis angle representation

Euler's finite rotation result states that any proper relative orientation in three dimensions can be represented by a rotation through some angle $\theta$ about some axis. Let

$\displaystyle \widehat{\mathbf u} =u_x\mathbf i+u_y\mathbf j+u_z\mathbf k, \qquad u_x^2+u_y^2+u_z^2=1.$ (6)

The geometric axis $\widehat{\mathbf u}$ is identified with a pure quaternion. Because it is a unit pure quaternion,

$\displaystyle \widehat{\mathbf u}^{\,2}=-1.$ (7)

Thus an arbitrary spatial unit axis behaves algebraically like an imaginary unit.

The pair

$\displaystyle (\widehat{\mathbf u},\theta) $

will mean throughout this article that frame $B$ is obtained from frame $A$ by a positive right handed rotation through $\theta$ about $\widehat{\mathbf u}$.

In engineering the same information is often packaged into the frame rotation vector

$\displaystyle \boldsymbol\theta = \theta\widehat{\mathbf u}.$ (8)

Its direction is the Euler axis and its magnitude is the frame rotation angle. Under the PhysicsLibrary passive quaternion convention, the quaternion vector part points in the opposite direction from $\boldsymbol\theta$ for principal positive rotations.

Unit quaternions and quaternion exponentials

Since $\widehat{\mathbf u}^{\,2}=-1$, the power series expansion of the quaternion exponential separates into even and odd powers exactly as it does for the complex exponential:

$\displaystyle \exp(-\widehat{\mathbf u}\phi) = \cos\phi-\widehat{\mathbf u}\sin\phi.$ (9)

Indeed,

\begin{equation*} \begin{aligned} \exp(-\widehat{\mathbf u}\phi) &=1-\widehat{\m... ...-\frac{\phi^3}{3!}+\frac{\phi^5}{5!}-\cdots\right). \end{aligned}\end{equation*}

Therefore a quaternion of the form

$\displaystyle q = \cos\phi-\widehat{\mathbf u}\sin\phi$ (10)

has unit norm, because

\begin{equation*}\begin{aligned} \lVert q\rVert^2 &=\cos^2\phi +\lVert\widehat{\... ...Vert^2\sin^2\phi\ &=\cos^2\phi+\sin^2\phi\ &=1. \end{aligned}\end{equation*}

Hence $q$ is a unit quaternion, and

$\displaystyle q^{-1}=q^*.$ (12)

For the passive frame map,

$\displaystyle {}^{B}q_A = \exp\left(-\frac{\theta}{2}\widehat{\mathbf u}\right).$ (13)

The conjugate,

$\displaystyle ({}^{B}q_A)^* = \exp\left(+\frac{\theta}{2}\widehat{\mathbf u}\right),$ (14)

is both the inverse coordinate map ${}^{A}q_B$ and the usual positive angle active rotor associated with the same relative geometry.

Why the quaternion uses half the frame rotation angle

The half angle can be seen with a minimal coordinate transformation calculation. Let $\mathbf v$ be a unit vector perpendicular to the rotation axis $\widehat{\mathbf u}$, and define

$\displaystyle \mathbf w = \widehat{\mathbf u}\times\mathbf v.$ (15)

For Hamilton multiplication and perpendicular pure quaternions,

$\displaystyle \widehat{\mathbf u}\mathbf v=\mathbf w, \qquad \mathbf v\widehat{... ...=-\mathbf w, \qquad \widehat{\mathbf u}\mathbf v\widehat{\mathbf u}=\mathbf v. $

Now write the candidate passive quaternion as

$\displaystyle q = \cos\phi-\widehat{\mathbf u}\sin\phi = c-s\widehat{\mathbf u},$ (16)

where $c=\cos\phi$ and $s=\sin\phi$. Since $q$ is unit,

$\displaystyle q^*=c+s\widehat{\mathbf u}.$ (17)

Applying the passive sandwich to the perpendicular test vector gives

\begin{equation*}\begin{aligned} q\mathbf v q^* &=(c-s\widehat{\mathbf u})\mathb... ...at{\mathbf u}\ &=(c^2-s^2)\mathbf v-2cs\mathbf w. \end{aligned}\end{equation*}

Using the double angle identities,

$\displaystyle q\mathbf v q^* = \cos(2\phi)\mathbf v - \sin(2\phi)\mathbf w.$ (19)

The coordinate representation of the fixed physical vector has therefore rotated through $-2\phi$ in the plane perpendicular to $\widehat{\mathbf u}$. That is exactly what must occur when the coordinate frame itself rotates positively through $+2\phi$.

Hence the positive frame rotation angle is

$\displaystyle \theta=2\phi.$ (20)

Consequently the passive unit quaternion for a positive frame rotation through $\theta$ is

$\displaystyle {}^{B}q_A = \cos\frac{\theta}{2} - \widehat{\mathbf u}\sin\frac{\theta}{2} = \exp\left(-\frac{\theta}{2}\widehat{\mathbf u}\right).$ (21)

The minus sign determines the passive direction; the factor of one half comes from the two sided sandwich action.

This perpendicular vector calculation establishes the half angle and the passive sign. The next article carries out the general coordinate transformation for an arbitrary vector with components both parallel and perpendicular to the rotation axis.

Scalar first component form

With

$\displaystyle \widehat{\mathbf u} = u_x\mathbf i+u_y\mathbf j+u_z\mathbf k, $

the passive axis angle quaternion becomes

$\displaystyle {}^{B}q_A = \begin{bmatrix} \cos(\theta/2)\ -u_x\sin(\theta/2)\ -u_y\sin(\theta/2)\ -u_z\sin(\theta/2) \end{bmatrix}.$ (22)

Thus

$\displaystyle q_w = \cos\frac{\theta}{2}, \qquad \mathbf q = -\widehat{\mathbf u}\sin\frac{\theta}{2}.$ (23)

For a principal positive frame rotation, the quaternion vector part points opposite the positive frame rotation axis. This is the passive counterpart of the familiar active rotor, whose vector part points along $+\widehat{\mathbf u}$.

Recovering frame axis and angle from a unit quaternion

Suppose

$\displaystyle {}^{B}q_A=q_w+\mathbf q, \qquad \lVert{}^{B}q_A\rVert=1.$ (24)

Define

$\displaystyle s=\lVert\mathbf q\rVert.$ (25)

For a principal positive frame rotation with

$\displaystyle 0\leq\theta\leq\pi, $

a numerically useful extraction is

$\displaystyle \theta = 2\operatorname{atan2}(s,q_w).$ (26)

When $s\neq0$, the positive frame rotation axis is

$\displaystyle \widehat{\mathbf u} = -\frac{\mathbf q}{s}.$ (27)

The minus sign is essential under the PhysicsLibrary passive convention.

The equivalent expression

$\displaystyle \theta=2\arccos(q_w) $

is common, but $\operatorname{atan2}$ uses both scalar and vector information and is generally preferable in numerical software. The quaternion should be normalized before extracting an angle.

If a principal rotation with

$\displaystyle 0\leq\theta\leq\pi $

is desired, a common engineering choice is first to replace ${}^{B}q_A$ by $-{}^{B}q_A$ when $q_w<0$. This selects the representative with nonnegative scalar part and therefore chooses the shorter equivalent frame rotation.

An equally valid alternative is to extract the axis and angle of the coordinate motion rather than of the positive frame rotation. In that interpretation the coordinate motion axis is

$\displaystyle \widehat{\mathbf u}_{\rm coord} = \frac{\mathbf q}{s},$ (28)

and the coordinate motion angle is $-\theta$. PhysicsLibrary uses the positive frame axis and angle as the canonical axis angle pair.

The sign ambiguity: $q$ and $-q$

A unit quaternion and its negative represent the same frame to frame coordinate transformation. The passive action satisfies

$\displaystyle (-q)\,v\,(-q)^* = qvq^*.$ (29)

Therefore the mapping from unit quaternions to proper frame orientations is two to one. This is the practical source of the familiar sign ambiguity in attitude data.

The passive axis angle form makes the same fact visible. Increasing the positive frame angle by $2\pi$ gives

\begin{equation*}\begin{aligned} {}^{B}q_A(\theta+2\pi) &= \cos\left(\frac{\thet... ...rac{\theta}{2}+\pi\right)\ &= -{}^{B}q_A(\theta). \end{aligned}\end{equation*}

A further $2\pi$ returns to the same quaternion:

$\displaystyle {}^{B}q_A(\theta+4\pi) = {}^{B}q_A(\theta).$ (31)

The deeper $S^3$ and $SU(2)$ interpretation of this double covering belongs to the later mathematical branch of the PhysicsLibrary quaternion sequence.

Important special cases

Zero frame rotation

For $\theta=0$,

$\displaystyle {}^{B}q_A=1.$ (32)

The frames coincide. The axis is physically irrelevant and therefore undefined. This is why axis extraction becomes ill conditioned when the vector part of the quaternion is very small.

Frame rotation through $\pi$ radians

For $\theta=\pi$,

$\displaystyle {}^{B}q_A = -\widehat{\mathbf u}.$ (33)

The scalar part is zero. Because $q$ and $-q$ represent the same orientation,

$\displaystyle +\widehat{\mathbf u}$ (34)

represents the same $180^\circ$ orientation as well. This is consistent with the geometric fact that at $180^\circ$, reversing the axis gives an equivalent axis angle description.

Frame rotation through $2\pi$ radians

For $\theta=2\pi$,

$\displaystyle {}^{B}q_A=-1.$ (35)

This is the same physical frame orientation as ${}^{B}q_A=+1$, although the quaternion itself has changed sign.

Small angle form used in engineering

Let the positive frame rotation vector be

$\displaystyle \boldsymbol\theta = \theta\widehat{\mathbf u}. $

For a small frame rotation, $\vert\theta\vert\ll1$ rad,

$\displaystyle \cos\frac{\theta}{2} \approx 1-\frac{\theta^2}{8}, \qquad \sin\frac{\theta}{2} \approx \frac{\theta}{2}. $

Therefore the passive frame quaternion satisfies

$\displaystyle {}^{B}q_A \approx 1-\frac12\boldsymbol\theta$ (36)

when the rotation vector is identified with a pure quaternion.

In scalar first components,

$\displaystyle {}^{B}q_A \approx \begin{bmatrix} 1\ -\tfrac12\theta_x\ -\tfrac12\theta_y\ -\tfrac12\theta_z \end{bmatrix}.$ (37)

This negative sign is important in attitude error filters, inertial navigation, and local frame linearizations. A formula using

$\displaystyle [\,1,\ +\tfrac12\delta\boldsymbol\theta\,] $

may still be correct, but it is using either the inverse frame map, an active rotation increment, or an oppositely defined error vector.

The approximation above is first order. The quaternion should not be assumed to have exactly unit norm after arbitrary finite updates unless it is renormalized or constructed from the exact trigonometric formula.

Passive and active interpretation

The defining equation of this article,

$\displaystyle {}^{B}q_A = \cos\frac{\theta}{2} - \widehat{\mathbf u}\sin\frac{\theta}{2},$ (38)

represents a positive frame rotation through $+\theta$ about $\widehat{\mathbf u}$ and acts passively on coordinates:

$\displaystyle {}^{B}v = {}^{B}q_A\,{}^{A}v\,({}^{B}q_A)^*.$ (39)

The conjugate is

$\displaystyle ({}^{B}q_A)^* = {}^{A}q_B = \cos\frac{\theta}{2} + \widehat{\mathbf u}\sin\frac{\theta}{2}.$ (40)

The same numerical quaternion also serves as the familiar positive active rotor for rotating a physical vector through $+\theta$ about the same right hand rule axis in a fixed frame:

$\displaystyle v' = ({}^{B}q_A)^*\,v\,{}^{B}q_A.$ (41)

Equivalently, if

$\displaystyle q_{\rm act} = \cos\frac{\theta}{2} + \widehat{\mathbf u}\sin\frac{\theta}{2},$ (42)

then

$\displaystyle q_{\rm act} = ({}^{B}q_A)^*.$ (43)

For a positive $90^\circ$ rotation of frame $B$ relative to frame $A$ about $+\widehat{\mathbf z}$,

$\displaystyle {}^{B}q_A = \frac{\sqrt2}{2} - \frac{\sqrt2}{2}\mathbf k.$ (44)

A fixed vector with

$\displaystyle {}^{A}\mathbf v = \begin{bmatrix} 1\\ 0\\ 0 \end{bmatrix}$ (45)

has coordinates

$\displaystyle {}^{B}\mathbf v = \begin{bmatrix} 0\\ -1\\ 0 \end{bmatrix}.$ (46)

By contrast, the conjugate active rotor sends a physical $+\widehat{\mathbf x}$ vector to $+\widehat{\mathbf y}$ in a fixed frame.

The sign change must not be confused with scalar first versus scalar last storage or with Hamilton versus flipped quaternion multiplication. Those are separate convention choices established in the PhysicsLibrary convention entry.

Relationship to passive direction cosine matrices

The passive axis angle quaternion is designed to agree directly with the PhysicsLibrary direction cosine matrix convention.

For the same positive frame rotation,

$\displaystyle {}^{B}\mathbf v = {}^{B}q_A\,{}^{A}v\,({}^{B}q_A)^* = {}^{B}C_A\,{}^{A}\mathbf v.$ (47)

For a rotation about $+\widehat{\mathbf z}$,

$\displaystyle {}^{B}q_A = \cos\frac{\theta}{2} - \mathbf k\sin\frac{\theta}{2},$ (48)

corresponding to

$\displaystyle {}^{B}C_A = \begin{bmatrix} \cos\theta&\sin\theta&0\ -\sin\theta&\cos\theta&0\ 0&0&1 \end{bmatrix}.$ (49)

At $\theta=90^\circ$ this matrix maps

$\displaystyle [1,0,0]^T_A $

to

$\displaystyle [0,-1,0]^T_B, $

exactly as the quaternion does.

This quaternion DCM agreement is one of the central convention checks used throughout the revised PhysicsLibrary orientation series.

Connection to intrinsic Euler sequences

Axis angle representation describes one finite frame rotation. Euler Angles describe the same final orientation through a sequence of elementary frame rotations.

PhysicsLibrary interprets named Euler sequences intrinsically. For an intrinsic $i$$j$$k$ sequence with successive positive frame angles $\alpha,\beta,\gamma$, define

$\displaystyle q_i^P(\alpha) = \cos\frac{\alpha}{2} - \mathbf e_i\sin\frac{\alpha}{2},$ (50)

and similarly for the second and third axes. Frame chaining gives

$\displaystyle {}^{B}q_A = q_k^P(\gamma)\, q_j^P(\beta)\, q_i^P(\alpha).$ (51)

The corresponding passive DCM is

$\displaystyle {}^{B}C_A = C_k(\gamma)\, C_j(\beta)\, C_i(\alpha).$ (52)

Thus the quaternion and DCM products have the same factor order.

For the common intrinsic $3$$2$$1$ yaw pitch roll sequence,

$\displaystyle {}^{B}q_A = q_1^P(\phi)\, q_2^P(\theta)\, q_3^P(\psi),$ (53)

where $\psi$ is yaw, $\theta$ is pitch, and $\phi$ is roll.

Common pitfalls

  1. Forgetting to normalize the axis. The vector $\widehat{\mathbf u}$ in the passive axis angle formula must have unit length.
  2. Using the full angle inside the sine and cosine. The quaternion phase is $\theta/2$ because the sandwich action produces twice the quaternion phase.
  3. Using the active sign for a passive frame quaternion. For a positive frame rotation,

    $\displaystyle {}^{B}q_A = \cos(\theta/2)-\widehat{\mathbf u}\sin(\theta/2). $
    The plus sign belongs to the conjugate active rotor or inverse passive map.
  4. Extracting the frame axis without the passive minus sign. For the principal passive quaternion,

    $\displaystyle \widehat{\mathbf u} = -\mathbf q/\lVert\mathbf q\rVert. $
  5. Treating $q$ and $-q$ as different orientations. They are distinct points on the unit quaternion sphere but represent the same proper frame orientation.
  6. Extracting an axis at zero rotation. When $\lVert\mathbf q\rVert\approx0$, the rotation axis is physically indeterminate and numerically poorly conditioned.
  7. Using $q^*$ as an inverse for a nonunit quaternion. The identity $q^{-1}=q^*$ holds only when $\lVert q\rVert=1$.
  8. Changing signs to match another source without checking its convention. Active/passive interpretation, frame direction, axis angle sign, and Hamilton/flipped multiplication can each alter the appearance of formulas.
  9. Assuming a small positive frame rotation gives a positive quaternion vector part. Under the PhysicsLibrary passive convention,

    $\displaystyle \mathbf q\approx-\frac12\boldsymbol\theta. $

What comes next

The passive axis angle formula produces the unit quaternion associated with a finite frame orientation. The next PhysicsLibrary article, rotating vectors with quaternions, is being revised into a frame coordinate transformation article. Under the present convention it derives

$\displaystyle {}^{B}v = {}^{B}q_A\,{}^{A}v\,({}^{B}q_A)^*$ (54)

and reduces the vector part to the passive Rodrigues form

$\displaystyle {}^{B}\mathbf v = {}^{A}\mathbf v\cos\theta - (\widehat{\mathbf u... ...+ \widehat{\mathbf u} (\widehat{\mathbf u}\cdot{}^{A}\mathbf v) (1-\cos\theta),$ (55)

with the usual care that all vector quantities in a single algebraic cross product expression must be resolved in a common basis.

A separate companion entry, Axis Angle Representation and Unit Quaternion: Examples, Exercises, and Solutions, provides a self study problem set with all exercises stated before the solutions and uses the same passive signs established here.

Sources and historical notes

Hamilton's Elements of Quaternions develops the versor as the unit quaternion carrying axis and angle information. Joly gives a clear historical statement that the transformation $q(\cdot)q^{-1}$ rotates vectors about the axis of $q$ through twice the quaternion's angle. Hathaway develops finite rotations before introducing quaternions, making the axis angle geometry explicit. Macfarlane similarly uses half angle versors in the composition of finite rotations.

Those historical treatments are valuable for understanding the algebraic origin of the half angle, but their rotation language should not be assumed to match the modern PhysicsLibrary frame map convention term for term. The revised PhysicsLibrary convention uses the passive scalar first Hamilton form

$\displaystyle {}^{B}q_A = \cos\frac{\theta}{2} - \widehat{\mathbf u}\sin\frac{\theta}{2}.$ (56)

Its conjugate,

$\displaystyle \cos\frac{\theta}{2} + \widehat{\mathbf u}\sin\frac{\theta}{2},$ (57)

is the conventional positive active rotor used in many historical and modern derivations. The two contain the same half angle geometry and represent inverse operations.

The convention itself is established in Quaternions for Physics and Engineering: Orientation, Notation, and Conventions.

Bibliography

1
W. R. Hamilton, Elements of Quaternions, 2nd ed., Vol. I, edited by C. J. Joly, Longmans, Green, and Co., London, 1899. Public domain historical source. Internet Archive copy https://archive.org/details/elementsofquater01hamiuoft
2
C. J. Joly, A Manual of Quaternions, Macmillan and Co., London, 1905. Public domain historical source.
3
A. S. Hathaway, A Primer of Quaternions, 1896. Public domain text; Project Gutenberg edition and LATEX source available. Project Gutenberg edition https://www.gutenberg.org/ebooks/9934
4
A. Macfarlane, Vector Analysis and Quaternions, John Wiley & Sons, New York, 1906. Public domain historical source; Project Gutenberg edition available. Project Gutenberg edition https://www.gutenberg.org/ebooks/13609

License

Unless otherwise noted, this PhysicsLibrary entry is intended for release under the Creative Commons Attribution ShareAlike 4.0 International license.



"Axis Angle Representation and Unit Quaternion" is owned by bloftin.
(view preamble)
View style:
See Also: quaternion series overview and article guide, Notation Quaternions for Physics and Engineering: Orientation, quaternion definition and basic algebra, example of quaternion definition and basic algebra, quaternion product, example of quaternion product, quaternion conjugate, example of quaternion conjugate, quaternion norm, example of quaternion norm, quaternion inverse, example of quaternion inverse

Keywords:  quaternion, unit quaternion, axis angle, Euler axis, rotation, rigid body attitude, versor, half angle, rotation vector

Attachments:
example of Axis Angle Representation and Unit Quaternion (Example) by bloftin

Cross-references: operations, composition, cross product, rotating vectors with quaternions, Euler Angles, matrix, direction cosine matrix, covering, representation, identities, norm, powers, power series, magnitude, quaternion multiplication, scalar, relation, formula, motion, vector, algebraic, quaternions, reference frame, unit vector, rigid body
There are 3 references to this object.

This is version 2 of Axis Angle Representation and Unit Quaternion, born on 2026-08-23, modified 2026-08-26.
Object id is 1095, canonical name is AxisAngleRepresentationAndUnitQuaternion.
Accessed 99 times total.

Classification:
Physics Classification02.40.Yy (Geometric mechanics )
 02.10.Hh (Rings and algebras)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

Interact
rate | post | correct | update request | add derivation | add example | add (any)