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
relative attitude and error quaternions (Definition)

Relative Attitude and Error Quaternions

An attitude quaternion describes the orientation of one frame relative to another. In estimation and control, however, the quantity of immediate interest is often not the attitude itself but the difference between two attitudes.

Examples include:

  • the difference between a commanded spacecraft attitude and the measured attitude;
  • the difference between the true attitude and a filter estimate;
  • the relative orientation between two vehicles;
  • the correction that must be injected into a nominal quaternion state;
  • the small attitude error used in a Kalman filter or feedback controller.

Attitude error is not obtained by subtracting quaternion components. Because three dimensional orientation is a noncommutative rotation group, the exact relative attitude is formed by quaternion multiplication with an inverse.

PhysicsLibrary uses passive frame quaternions. Let

$\displaystyle q = {}^{B}q_I$ (1)

denote the current or actual attitude, mapping reference frame $I$ coordinates into actual body frame $B$ coordinates.

Let

$\displaystyle q_d = {}^{D}q_I$ (2)

denote the desired attitude, mapping the same reference frame coordinates into desired frame $D$ coordinates.

Two multiplicative error definitions are useful:

$\displaystyle \delta q_L = q_d q^*$ (3)

and

$\displaystyle \delta q_R = q^*q_d.$ (4)

They are called the left and right errors because they reconstruct the desired attitude as

$\displaystyle q_d = \delta q_L q$ (5)

or

$\displaystyle q_d = q\delta q_R.$ (6)

Both represent the same physical relative orientation, but their vector parts are resolved on different sides of the attitude transformation.

Convention declaration

PhysicsLibrary 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.

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}.$ (7)

The canonical passive coordinate map is

$\displaystyle {}^{B}v = {}^{B}q_I \,{}^{I}v \,({}^{B}q_I)^*.$ (8)

For a positive frame rotation through angle $\theta$ about unit axis $\widehat{\mathbf u}$,

$\displaystyle q = \cos\frac{\theta}{2} - \widehat{\mathbf u} \sin\frac{\theta}{2}.$ (9)

This negative vector sign is essential when converting an error quaternion to a physical small frame rotation vector.

Why subtraction is not an attitude error

A quaternion is not an ordinary vector in orientation space.

The component difference

$\displaystyle q_d-q $

is a four dimensional Euclidean difference between two parameter vectors. It is not itself a unit quaternion and does not directly represent the finite rotation that carries one attitude into the other.

The exact relative transformation must instead satisfy a composition equation.

For a left error,

$\displaystyle q_d = \delta q_L q. $

Right multiply by $q^*$:

$\displaystyle q_dq^* = \delta q_Lqq^* = \delta q_L. $

Therefore

$\displaystyle \delta q_L=q_dq^*.$ (10)

For a right error,

$\displaystyle q_d = q\delta q_R. $

Left multiply by $q^*$:

$\displaystyle q^*q_d = q^*q\delta q_R = \delta q_R. $

Therefore

$\displaystyle \delta q_R=q^*q_d.$ (11)

Geometric interpretation of the left error

Because

$\displaystyle q={}^Bq_I $

and

$\displaystyle q_d={}^Dq_I, $

the conjugate of the current attitude is

$\displaystyle q^* = {}^Iq_B. $

Therefore the left error has the explicit frame chain

\begin{equation*} \begin{aligned} \delta q_L &= {}^Dq_I\,{}^Iq_B\ &= {}^Dq_B. \end{aligned}\end{equation*}

Hence

$\displaystyle \delta q_L = {}^Dq_B.$ (12)

The left error is the direct passive coordinate transformation from the current actual frame into the desired frame.

It is therefore especially natural when the correction is applied on the body or output side:

$\displaystyle q_d = \delta q_L q. $

Geometric interpretation of the right error

The right error is

$\displaystyle \delta q_R=q^*q_d. $

It reconstructs the desired attitude by right multiplication:

$\displaystyle q_d=q\delta q_R. $

The right error is the same relative rotation transported to the reference or input side of the current attitude transformation.

The two errors are related exactly by conjugation.

Starting from

$\displaystyle \delta q_R=q^*q_d, $

multiply on the left by $q$ and on the right by $q^*$:

$\displaystyle q\delta q_Rq^* = qq^*q_dq^* = q_dq^*. $

Thus

$\displaystyle \delta q_L = q\delta q_Rq^*.$ (13)

Equivalently,

$\displaystyle \delta q_R = q^*\delta q_Lq.$ (14)

This relation explains why left and right errors have the same scalar part and the same rotation magnitude but generally different vector components.

Relative attitude diagram

The following diagram summarizes the passive frame maps and the two multiplicative errors.

Image Q12_relative_attitude_error_quaternion

Figure. The actual passive attitude is $q={}^Bq_I$ and the desired passive attitude is $q_d={}^Dq_I$. The left error is the direct actual to desired frame map $\delta q_L=q_dq^*$ and is applied on the left. The right error $\delta q_R=q^*q_d$ is the conjugate transported version applied on the right. For a small positive frame error, the quaternion vector part has the opposite sign from the physical rotation vector.

Direction cosine matrix form

Let

$\displaystyle C=C(q) $

and

$\displaystyle C_d=C(q_d) $

be the passive DCMs.

Because

$\displaystyle C(pq)=C(p)C(q) $

and

$\displaystyle C(q^*)=C(q)^T, $

the left error matrix is

$\displaystyle E_L = C(\delta q_L) = C_dC^T.$ (15)

The right error matrix is

$\displaystyle E_R = C(\delta q_R) = C^TC_d.$ (16)

The exact conjugation relation becomes

$\displaystyle E_L = CE_RC^T.$ (17)

Thus the quaternion and DCM error definitions are completely consistent.

Exact axis angle form of a passive error quaternion

Choose a unit error quaternion

$\displaystyle \delta q = \delta q_w+\delta\mathbf q_v. $

Under the PhysicsLibrary passive convention,

$\displaystyle \delta q = \cos\frac{\delta\theta}{2} - \widehat{\mathbf u}_e \sin\frac{\delta\theta}{2}.$ (18)

For a principal representative with

$\displaystyle \delta q_w\geq0, $

the principal error angle is

$\displaystyle \delta\theta = 2\operatorname{atan2} \left( \lVert\delta\mathbf q_v\rVert, \delta q_w \right).$ (19)

If the vector part is nonzero, the corresponding positive frame error axis is

$\displaystyle \widehat{\mathbf u}_e = - \frac{ \delta\mathbf q_v }{ \lVert\delta\mathbf q_v\rVert }.$ (20)

The minus sign is the passive counterpart of the usual active axis extraction formula.

Principal sign choice

The unit quaternions

$\displaystyle \delta q $

and

$\displaystyle -\delta q $

represent the same physical relative attitude.

For local estimation and control, it is usually convenient to choose the representative with nonnegative scalar component:

$\displaystyle \delta q_w\geq0.$ (21)

This selects a principal error angle in the interval

$\displaystyle 0\leq\delta\theta\leq\pi.$ (22)

If an initially computed error has

$\displaystyle \delta q_w<0, $

replace it by

$\displaystyle -\delta q $

before forming a local small error vector.

At exactly $180^\circ$,

$\displaystyle \delta q_w=0, $

and the sign choice is intrinsically ambiguous. The two quaternion signs are equally valid at that point.

Small attitude error approximation

For a small positive frame error vector

$\displaystyle \delta\boldsymbol\theta = \widehat{\mathbf u}_e \,\delta\theta, $

use

$\displaystyle \cos\frac{\delta\theta}{2} \approx1 $

and

$\displaystyle \sin\frac{\delta\theta}{2} \approx \frac{\delta\theta}{2}. $

Then the passive error quaternion becomes

$\displaystyle \delta q \approx 1 - \frac12 \delta\boldsymbol\theta.$ (23)

In scalar first array notation,

$\displaystyle \delta\mathbf q \approx \begin{bmatrix} 1\ -\frac12\delta\boldsymbol\theta \end{bmatrix}.$ (24)

Therefore the physical small frame error vector is recovered from the quaternion vector part by

$\displaystyle \delta\boldsymbol\theta \approx -2\delta\mathbf q_v.$ (25)

This is one of the most important sign changes from an active quaternion error model.

Left and right small error vectors

Let

$\displaystyle \delta\boldsymbol\theta_L $

denote the small frame error vector associated with $\delta q_L$, and let

$\displaystyle \delta\boldsymbol\theta_R $

denote the small frame error vector associated with $\delta q_R$.

The exact quaternion relation is

$\displaystyle \delta q_L = q\delta q_Rq^*. $

To first order,

$\displaystyle \delta q_R \approx 1 - \frac12\delta\boldsymbol\theta_R. $

Therefore

\begin{equation*} \begin{aligned} \delta q_L &\approx q \left( 1-\frac12\delta\b... ...^*\ &= 1 - \frac12 q\delta\boldsymbol\theta_Rq^*. \end{aligned}\end{equation*}

The quaternion sandwich transforms pure vector coordinates according to the current passive attitude:

$\displaystyle q\delta\boldsymbol\theta_Rq^* = C(q)\delta\boldsymbol\theta_R. $

Hence

$\displaystyle \delta\boldsymbol\theta_L = C(q) \delta\boldsymbol\theta_R.$ (26)

Equivalently,

$\displaystyle \delta\boldsymbol\theta_R = C(q)^T \delta\boldsymbol\theta_L.$ (27)

Thus the left and right small errors represent the same geometric misalignment in different coordinate resolutions.

Check: desired yaw differs by $15^\circ$

Suppose the current passive attitude is a positive $10^\circ$ frame yaw about $+\widehat{\mathbf z}$:

$\displaystyle q = \cos5^\circ - \mathbf k\sin5^\circ. $

Suppose the desired attitude is a positive $25^\circ$ frame yaw:

$\displaystyle q_d = \cos12.5^\circ - \mathbf k\sin12.5^\circ. $

Because both rotations use the same axis, they commute. The left error is

\begin{equation*} \begin{aligned} \delta q_L &= q_dq^*\ &= \left( \cos12.5^\ci... ... \left( \cos5^\circ + \mathbf k\sin5^\circ \right). \end{aligned}\end{equation*}

Therefore

$\displaystyle \delta q_L = \cos7.5^\circ - \mathbf k\sin7.5^\circ.$ (28)

This is the passive quaternion for a positive $15^\circ$ frame error about $+\widehat{\mathbf z}$.

The exact physical error is therefore

$\displaystyle \delta\theta=15^\circ, \qquad \widehat{\mathbf u}_e=+\widehat{\mathbf z}.$ (29)

Check: left and right errors need not be equal

Take the current attitude as a positive $90^\circ$ frame rotation about $+x$:

$\displaystyle q = \frac{1-\mathbf i}{\sqrt2}.$ (30)

Take the desired attitude as a positive $90^\circ$ frame rotation about $+y$:

$\displaystyle q_d = \frac{1-\mathbf j}{\sqrt2}.$ (31)

The current conjugate is

$\displaystyle q^* = \frac{1+\mathbf i}{\sqrt2}. $

The left error is

\begin{equation*} \begin{aligned} \delta q_L &= q_dq^*\ &= \frac12 (1-\mathbf ... ...i)\ &= \frac12 (1+\mathbf i-\mathbf j+\mathbf k). \end{aligned}\end{equation*}

Thus

$\displaystyle \delta q_L = \frac12 (1+\mathbf i-\mathbf j+\mathbf k).$ (32)

The right error is

\begin{equation*} \begin{aligned} \delta q_R &= q^*q_d\ &= \frac12 (1+\mathbf ... ...j)\ &= \frac12 (1+\mathbf i-\mathbf j-\mathbf k). \end{aligned}\end{equation*}

Thus

$\displaystyle \delta q_R = \frac12 (1+\mathbf i-\mathbf j-\mathbf k).$ (33)

The two errors have the same scalar part and the same vector magnitude but different vector directions.

Finite attitude error is therefore convention sensitive even when the error angle itself is unchanged.

Same physical attitude with opposite quaternion signs

Suppose the stored current and desired quaternions satisfy

$\displaystyle q_d=-q. $

They represent exactly the same physical attitude.

The left error is

$\displaystyle \delta q_L = q_dq^* = -qq^* = -1. $

Thus

$\displaystyle \delta q_L=-1.$ (34)

The quaternion $-1$ represents the identity orientation just as $+1$ does.

For a local error representation, change the sign to the principal representative

$\displaystyle \delta q_L=+1.$ (35)

The physical attitude error is zero, not $360^\circ$.

Desired versus actual attitude in control

For control, let

$\displaystyle q $

be the measured or estimated actual passive attitude and let

$\displaystyle q_d $

be the commanded passive attitude.

A body side correction can be formed with

$\displaystyle \delta q_L=q_dq^*. $

For a small error,

$\displaystyle \delta q_L \approx 1-\frac12\delta\boldsymbol\theta_L. $

Therefore a controller that requires a physical positive frame correction vector should use

$\displaystyle \delta\boldsymbol\theta_L \approx -2\,\operatorname{sgn}(\delta q_{L,w}) \,\delta\mathbf q_{L,v},$ (36)

away from the $180^\circ$ sign ambiguity.

The sign factor selects the locally shortest quaternion representative.

A control law should not use the raw quaternion vector part without first accounting for the active or passive convention.

True versus estimated attitude in estimation

Let the true passive attitude be

$\displaystyle q_t $

and a nominal estimate be

$\displaystyle \widehat q. $

A left multiplicative error is defined by

$\displaystyle q_t = \delta q_L\widehat q.$ (37)

Therefore

$\displaystyle \delta q_L = q_t\widehat q^*.$ (38)

A right multiplicative error is defined by

$\displaystyle q_t = \widehat q\delta q_R,$ (39)

so

$\displaystyle \delta q_R = \widehat q^*q_t.$ (40)

For a passive small error state,

$\displaystyle \delta q \approx \begin{bmatrix} 1\ -\frac12\delta\boldsymbol\theta \end{bmatrix}.$ (41)

The filter covariance, Jacobians, reset equation, and correction injection must all use the same left or right definition.

Error injection

Suppose an estimator has computed a correction quaternion $\delta\widehat q$.

For a left error model, update the nominal attitude by

$\displaystyle \widehat q^+ = \delta\widehat q \,\widehat q^-.$ (42)

For a right error model,

$\displaystyle \widehat q^+ = \widehat q^- \,\delta\widehat q.$ (43)

Mixing a right error covariance model with a left injection, or vice versa, changes the coordinate interpretation of the correction and is generally inconsistent.

Relative attitude between two physical bodies

The same algebra applies when neither attitude is merely a desired command.

Let two physical frames $B_1$ and $B_2$ have passive attitudes

$\displaystyle {}^{B_1}q_I $

and

$\displaystyle {}^{B_2}q_I. $

The direct coordinate map from $B_1$ into $B_2$ is

$\displaystyle {}^{B_2}q_{B_1} = {}^{B_2}q_I ({}^{B_1}q_I)^*.$ (44)

This is exactly the same form as the left error quaternion.

Therefore relative attitude and attitude error are mathematically the same operation. The difference is the engineering interpretation assigned to the two endpoint frames.

Why Euler angle subtraction is generally not exact

Suppose the actual and desired attitudes are displayed as yaw, pitch, and roll triples.

The component difference

$\displaystyle \begin{bmatrix} \phi_d-\phi\ \theta_d-\theta\ \psi_d-\psi \end{bmatrix}$

is generally not the exact finite attitude error vector.

Euler Angles are nonlinear coordinates associated with an ordered sequence of rotations. Finite rotations do not commute, so subtracting the three coordinates does not reproduce the group product

$\displaystyle q_dq^* $

or

$\displaystyle q^*q_d. $

For sufficiently small errors and away from an Euler singularity, angle differences may provide a local approximation. The exact error should nevertheless be formed first with quaternions or DCMs.

Error near $180^\circ$

For a principal passive error quaternion,

$\displaystyle \delta q_w = \cos\frac{\delta\theta}{2}. $

Therefore

$\displaystyle \delta q_w\approx0 $

corresponds to

$\displaystyle \delta\theta\approx180^\circ. $

Near this angle, the two equivalent representatives $\delta q$ and $-\delta q$ have nearly equal scalar magnitude and opposite vector parts.

Consequently a rule that always forces a positive scalar component can switch sign under very small perturbations near $180^\circ$.

The physical orientation remains continuous. The discontinuity belongs to the chosen quaternion representative.

This issue is especially important in controllers, optimizers, and time histories that assume quaternion component continuity.

Exact error angle without choosing an axis sign

If only the magnitude of the principal attitude error is needed, choose the quaternion sign so that

$\displaystyle \delta q_w\geq0. $

Then

$\displaystyle \delta\theta = 2\arccos(\delta q_w).$ (45)

An equivalent numerically robust form is

$\displaystyle \delta\theta = 2\operatorname{atan2} \left( \lVert\delta\mathbf q_v\rVert, \delta q_w \right).$ (46)

The second form behaves well for both small and large angles.

Small error norm

The first order passive error quaternion is

$\displaystyle \delta q \approx \begin{bmatrix} 1\ -\frac12\delta\boldsymbol\theta \end{bmatrix}. $

Its squared Euclidean norm is

\begin{equation*} \begin{aligned} \lVert\delta q\rVert^2 &\approx 1 + \frac14 \lVert\delta\boldsymbol\theta\rVert^2. \end{aligned}\end{equation*}

Thus

$\displaystyle \lVert\delta q\rVert^2-1 = O \left( \lVert\delta\boldsymbol\theta\rVert^2 \right).$ (47)

The unit norm error introduced by the first order small error approximation is second order in the attitude error magnitude.

Implementation checks

A relative attitude implementation should pass the following checks.

  1. Identity.

    If

    $\displaystyle q_d=q, $

    then both errors must equal $+1$ up to quaternion sign.

  2. Opposite stored sign.

    If

    $\displaystyle q_d=-q, $

    the physical error must still be zero.

  3. Same axis rotations.

    For current yaw $10^\circ$ and desired yaw $25^\circ$, the passive error must represent a positive $15^\circ$ frame yaw and therefore have a negative $\mathbf k$ vector component.

  4. Left and right reconstruction.

    Verify

    $\displaystyle q_d=\delta q_Lq $

    and

    $\displaystyle q_d=q\delta q_R. $
  5. Conjugation relation.

    Verify

    $\displaystyle \delta q_L=q\delta q_Rq^*. $
  6. DCM consistency.

    Verify

    $\displaystyle C(\delta q_L)=C_dC^T $

    and

    $\displaystyle C(\delta q_R)=C^TC_d. $
  7. Small error sign.

    For a small positive frame rotation vector $\delta\boldsymbol\theta$, verify

    $\displaystyle \delta\mathbf q_v \approx -\frac12 \delta\boldsymbol\theta. $

Common pitfalls

  1. Subtracting quaternion components.

    The exact relative attitude is multiplicative, not additive.

  2. Using the old active small error sign.

    For the PhysicsLibrary passive frame quaternion,

    $\displaystyle \delta q \approx 1-\frac12\delta\boldsymbol\theta. $
  3. Calling an error simply “the quaternion difference.”

    The order must be stated. $q_dq^*$ and $q^*q_d$ are generally different.

  4. Mixing left error propagation with right error injection.

    The filter or controller must keep the chosen side consistent.

  5. Ignoring the $q$ versus $-q$ equivalence.

    An error quaternion near $-1$ can represent almost zero physical error.

  6. Forcing sign continuity and principal angle simultaneously without a policy.

    Near $180^\circ$, the principal sign choice can switch discontinuously.

  7. Interpreting the raw passive vector part as a positive physical correction vector.

    The small physical frame error is approximately $-2\delta\mathbf q_v$.

  8. Subtracting Euler angle triples for a large finite error.

    Euler coordinates are sequence dependent nonlinear coordinates, not a global rotation vector.

  9. Assuming left and right error vectors have the same coordinates.

    They represent the same geometric error but are transported through the current attitude.

Relationship to adjacent PhysicsLibrary entries

The preceding article, quaternion kinematics and angular velocity, derives the passive quaternion differential equations used to propagate the nominal attitude.

The present article defines exact relative attitude and multiplicative error quaternions and establishes the passive small error sign used in estimation and control.

A separate companion entry, Relative Attitude and Error Quaternions: Examples, Exercises, and Solutions, provides the Q12E self study problem bank.

The next main article, numerical quaternion propagation and IMU attitude state integration, combines quaternion kinematics, sampled gyro increments, bias correction, and small error concepts in a discrete navigation implementation.

Sources and convention notes

Relative attitude and multiplicative quaternion errors are standard tools in spacecraft attitude estimation, inertial navigation, robotics, and nonlinear state estimation. Their exact signs and multiplication sides depend on the chosen quaternion frame map.

Sommer and coauthors provide a modern discussion of quaternion convention management and passive frame transformations. Markley and Crassidis provide a broad spacecraft attitude treatment including quaternion errors and estimation. Shuster discusses historical spacecraft quaternion conventions. Solà provides a detailed engineering discussion of quaternion perturbations and error state Kalman filtering; its formulas should be translated carefully when the quaternion map differs from the PhysicsLibrary passive convention.

Bibliography

1
H. Sommer, I. Gilitschenski, M. Bloesch, S. Weiss, R. Siegwart, and J. Nieto, “Why and How to Avoid the Flipped Quaternion Multiplication,” Aerospace, vol. 5, no. 3, article 72, 2018. Published under CC BY 4.0. Publisher article https://www.mdpi.com/2226-4310/5/3/72
2
F. L. Markley and J. L. Crassidis, Fundamentals of Spacecraft Attitude Determination and Control, Springer, 2014. Engineering reference. Publisher book page https://link.springer.com/book/10.1007/978-1-4939-0802-8
3
M. D. Shuster, “The Nature of the Quaternion,” The Journal of the Astronautical Sciences, vol. 56, no. 3, pp. 359–373, 2008. Reference source. DOI record https://doi.org/10.1007/BF03256558
4
J. Solà, “Quaternion Kinematics for the Error State Kalman Filter,” technical report, 2017. arXiv preprint https://arxiv.org/abs/1711.02508

License

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



"relative attitude and error quaternions" 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

Other names:  relative attitude quaternion, error quaternion
Also defines:  error quaternions, relative attitude
Keywords:  quaternion, relative attitude, error quaternion, attitude error, multiplicative error, small angle error, spacecraft attitude, error state estimation, attitude control

Attachments:
example of relative attitude and error quaternions (Example) by bloftin

Cross-references: concepts, kinematics, numerical quaternion propagation and IMU attitude state integration, differential equations, quaternion kinematics and angular velocity, norm, forces, Euler Angles, operation, injection, covariance, representation, identity, commute, formula, matrix, diagram, magnitude, relation, conjugation, composition, parameter, scalar, vector, reference frame, quaternion multiplication, noncommutative, quaternion
There are 6 references to this object.

This is version 4 of relative attitude and error quaternions, born on 2026-08-24, modified 2026-08-27.
Object id is 1107, canonical name is RelativeAttitudeAndErrorQuaternions.
Accessed 125 times total.

Classification:
Physics Classification02.40.Yy (Geometric mechanics )
 02.10.Hh (Rings and algebras)
 45.40.-f (Dynamics and kinematics of rigid bodies)
Pending Errata and Addenda
None.
Discussion
Style: Expand: Order:

No messages.

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