<?xml version="1.0" encoding="UTF-8"?>

<record version="2" id="1107">
 <title>relative attitude and error quaternions</title>
 <name>RelativeAttitudeAndErrorQuaternions</name>
 <created>2026-08-24 02:26:13</created>
 <modified>2026-08-24 02:28:06</modified>
 <type>Definition</type>
 <creator id="1" name="bloftin"/>
 <modifier id="1" name="bloftin"/>
 <comment>converted to passive rotation convention</comment>
 <author id="1" name="bloftin"/>
 <classification>
	<category scheme="pacs" code="02.40.Yy"/>
	<category scheme="pacs" code="02.10.Hh"/>
	<category scheme="pacs" code="45.40.-f"/>
 </classification>
 <defines>
	<concept>error quaternions</concept>
	<concept>relative attitude</concept>
 </defines>
 <synonyms>
	<synonym concept="relative attitude and error quaternions" alias=" relative attitude quaternion"/>
	<synonym concept="relative attitude and error quaternions" alias="error quaternion"/>
 </synonyms>
 <keywords>
	<term>quaternion</term>
	<term>relative attitude</term>
	<term>error quaternion</term>
	<term>attitude error</term>
	<term>multiplicative error</term>
	<term>small angle error</term>
	<term>spacecraft attitude</term>
	<term>error state estimation</term>
	<term>attitude control</term>
 </keywords>
 <preamble>% this is the default PhysicsLibrary preamble.  as your knowledge
% of TeX increases, you will probably want to edit this, but
% it should be fine as is for beginners.

% almost certainly you want these
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}

% used for TeXing text within eps files
%\usepackage{psfrag}
% need this for including graphics (\includegraphics).
% If you use \includegraphics{figure} with no file extension, PhysicsLibrary
% will prefer figure.png before falling back to figure.eps.
\usepackage{graphicx}
\DeclareGraphicsExtensions{.png,.jpg,.jpeg,.pdf,.eps}
% for neatly defining theorems and propositions
%\usepackage{amsthm}
% making logically defined graphics
%\usepackage{xypic}

% there are many more packages, add them here as you need them

% define commands here</preamble>
 <content>\section*{Relative attitude and error quaternions}

An attitude quaternion describes an orientation relative to a reference frame.
In estimation and control, the more useful quantity is often the orientation
\emph{difference} between an actual attitude and a desired or estimated
attitude.  Because rotations form a noncommutative group, this difference is
not obtained by subtracting quaternion components.  It is obtained by forming a
relative rotation through quaternion multiplication and inversion.

The resulting unit quaternion is called a \emph{relative attitude quaternion}
or an \emph{error quaternion}.  It is exact for arbitrarily large attitude
differences.  When the error is small, its vector part reduces naturally to the
three component small rotation vector used in many Kalman filters and attitude
controllers.

\section{Convention declaration}

This article continues the PhysicsLibrary convention used in Q00 through Q11:
\begin{enumerate}
\item right-handed orthonormal frames;
\item Hamilton multiplication, so $\mathbf i\mathbf j=\mathbf k$;
\item scalar-first display notation,
\begin{equation}
q=q_w+q_x\mathbf i+q_y\mathbf j+q_z\mathbf k;
\end{equation}
\item the actual attitude quaternion is
\begin{equation}
q\equiv {}^{I}q_B,
\end{equation}
which maps body coordinates into the inertial or reference frame;
\item the desired attitude is denoted by $q_d$.
\end{enumerate}

Both $q$ and $q_d$ are assumed to be unit quaternions unless stated otherwise.

\section{Why quaternion subtraction is not attitude error}

The component difference
\begin{equation}
q_d-q
\end{equation}
is not itself an orientation.  It need not have unit norm, it depends on the
choice between the equivalent representatives $q$ and $-q$, and it does not
compose with attitude in the correct geometric way.

The correct error must instead satisfy a composition equation.  There are two
standard choices, depending on whether the correction multiplies the actual
attitude on the left or on the right.

\section{Left error and right error}

Define the \emph{left error quaternion} by requiring
\begin{equation}
\boxed{q_d=\delta q_I\,q.}
\end{equation}
Multiplying on the right by $q^*$ gives
\begin{equation}
\boxed{\delta q_I=q_dq^*.}
\end{equation}
This form expresses the relative correction on the inertial or reference side
of the attitude map.

Alternatively, define the \emph{right error quaternion} by
\begin{equation}
\boxed{q_d=q\,\delta q_B.}
\end{equation}
Multiplying on the left by $q^*$ gives
\begin{equation}
\boxed{\delta q_B=q^*q_d.}
\end{equation}
This form expresses the correction on the body side.

Both quaternions describe the same physical relative rotation.  They differ
only in the coordinates used for its rotation axis.  The two forms are related
by
\begin{equation}
\boxed{\delta q_I=q\,\delta q_B\,q^*.}
\end{equation}
Thus the vector part of the error transforms exactly as an ordinary spatial
vector under conjugation by the attitude quaternion.

\section{Geometry of the relative attitude}

Figure~\ref{fig:q12-error} shows the actual and desired orientations and the
relative correction between them.  The actual frame is rotated into the desired
frame by an error rotation with axis $\widehat{\mathbf u}_e$ and angle
$\delta\theta$.

\begin{figure}[h]
\centering
\includegraphics[width=0.88\textwidth]{Q12_relative_attitude_error_quaternion.png}
\caption{Relative attitude and the multiplicative error quaternion.  The actual
attitude $q$ and desired attitude $q_d$ are connected by either a left error
$q_d=\delta q_I q$ or a right error $q_d=q\delta q_B$.  The two error
quaternions represent the same physical rotation, resolved in different
coordinates.}
\label{fig:q12-error}
\end{figure}

\section{Axis angle interpretation of the error}

Any unit error quaternion may be written as
\begin{equation}
\boxed{
\delta q
=
\cos\frac{\delta\theta}{2}
+
\widehat{\mathbf u}_e\sin\frac{\delta\theta}{2}.
}
\end{equation}
Write
\begin{equation}
\delta q=\delta q_w+\delta\mathbf q_v.
\end{equation}
For a nonzero vector part, the error axis is
\begin{equation}
\boxed{
\widehat{\mathbf u}_e=
\frac{\delta\mathbf q_v}{\lVert\delta\mathbf q_v\rVert}.
}
\end{equation}
The exact error angle is most robustly obtained from
\begin{equation}
\boxed{
\delta\theta
=2\operatorname{atan2}
\left(\lVert\delta\mathbf q_v\rVert,\delta q_w\right).
}
\end{equation}

\section{Choosing the principal error}

The quaternions $\delta q$ and $-\delta q$ describe the same physical relative
orientation.  For feedback and local estimation it is usually convenient to
choose the representative whose scalar part is nonnegative:
\begin{equation}
\boxed{\delta q_w\ge 0.}
\end{equation}
This choice gives the principal rotation angle in the interval
\begin{equation}
0\le\delta\theta\le\pi.
\end{equation}

A convenient implementation rule is to replace
\begin{equation}
\delta q\leftarrow -\delta q
\end{equation}
whenever $\delta q_w&lt;0$, except when an application deliberately maintains a
different sign continuity convention.  Near $180^\circ$, the sign choice is
intrinsically ambiguous because the scalar part is close to zero.

\section{Small error approximation}

For small attitude error,
\begin{equation}
\delta\theta\ll 1,
\end{equation}
so
\begin{equation}
\cos\frac{\delta\theta}{2}\approx 1,
\qquad
\sin\frac{\delta\theta}{2}\approx\frac{\delta\theta}{2}.
\end{equation}
Define the small rotation vector
\begin{equation}
\delta\boldsymbol\theta
=\delta\theta\widehat{\mathbf u}_e.
\end{equation}
Then
\begin{equation}
\boxed{
\delta q
\approx
1+\frac12\delta\boldsymbol\theta
}
\end{equation}
when the rotation vector is identified with a pure quaternion.  In scalar-first
column form,
\begin{equation}
\boxed{
\delta q
\approx
\begin{bmatrix}
1\\[2mm]
\frac12\delta\boldsymbol\theta
\end{bmatrix}.
}
\end{equation}
Therefore, provided the error representative has been chosen near $+1$,
\begin{equation}
\boxed{
\delta\boldsymbol\theta
\approx 2\,\delta\mathbf q_v.
}
\end{equation}
This three component vector is the standard bridge between exact quaternion
error and linearized attitude error models.

\section{Left and right small error vectors}

From equation (8), a small right error and a small left error satisfy
\begin{equation}
\delta q_I=q\delta q_Bq^*.
\end{equation}
Using the small error form gives
\begin{equation}
1+\frac12\delta\boldsymbol\theta^I
\approx
q\left(1+\frac12\delta\boldsymbol\theta^B\right)q^*.
\end{equation}
The scalar part remains one and the vector part rotates according to Q07, so
\begin{equation}
\boxed{
\delta\boldsymbol\theta^I
=R(q)\,\delta\boldsymbol\theta^B
}
\end{equation}
to first order.  Thus the same small physical attitude error can be resolved in
inertial coordinates or body coordinates.

\section{Example: a spacecraft yaw correction}

Suppose the actual attitude is a $10^\circ$ yaw and the desired attitude is a
$20^\circ$ yaw.  Then
\begin{equation}
q=\cos5^\circ+\mathbf k\sin5^\circ,
\end{equation}
and
\begin{equation}
q_d=\cos10^\circ+\mathbf k\sin10^\circ.
\end{equation}
Because both rotations are about the same axis,
\begin{equation}
\begin{aligned}
\delta q_I
&amp;=q_dq^*\\
&amp;=\cos5^\circ+\mathbf k\sin5^\circ.
\end{aligned}
\end{equation}
Therefore the required correction is exactly a $10^\circ$ rotation about the
positive $z$ axis.

\section{Use in attitude estimation}

Many attitude estimators maintain a full unit quaternion as the nominal
attitude but use only three small variables for the local attitude error.  A
small correction may be formed as
\begin{equation}
\delta q(\delta\boldsymbol\theta)
\approx
\begin{bmatrix}
1\\[1mm]
\frac12\delta\boldsymbol\theta
\end{bmatrix},
\end{equation}
then injected into the nominal quaternion.  A left error estimator uses
\begin{equation}
\boxed{q^+=\delta q\,\widehat q,}
\end{equation}
while a right error estimator uses
\begin{equation}
\boxed{q^+=\widehat q\,\delta q.}
\end{equation}
The estimator equations and covariance must use the same error convention
consistently.  Mixing a left error covariance model with right error injection
is a common implementation mistake.

\section{Use in attitude control}

For control, the vector part of the principal error quaternion provides a
bounded directional measure of attitude error.  For small error,
\begin{equation}
2\delta\mathbf q_v\approx\delta\boldsymbol\theta,
\end{equation}
so a controller based on the error quaternion vector part reduces locally to a
controller based on the familiar small rotation vector.

For large errors, the exact quaternion should be retained rather than replacing
it with the linear approximation.  NASA spacecraft control work has long used
quaternion attitude error measures for this reason, including exact nonlinear
error formulations and comparisons with direction cosine formulations.

\section{Error quaternion versus Euler angle difference}

A raw Euler angle difference is not a geometric rotation vector for finite
errors.  If Euler angles are used for display or commands, convert the two
orientations to quaternions or matrices first and form the exact relative
rotation.  Only after the relative error is known to be small should one use the
three component approximation
\begin{equation}
\delta\boldsymbol\theta\approx2\delta\mathbf q_v.
\end{equation}
This avoids sequence dependence and Euler angle singularities.

\section{Common pitfalls}

The most common mistakes are:
\begin{enumerate}
\item subtracting quaternion components instead of forming a relative product;
\item confusing the left error $q_dq^*$ with the right error $q^*q_d$;
\item using the small angle approximation for a large attitude error;
\item forgetting that $\delta q$ and $ \delta q$ represent the same rotation;
\item allowing a sign flip to create an artificial error near $-1$ when the
physical attitude difference is near zero;
\item mixing an inertial resolved error vector with a body resolved covariance
or controller gain;
\item forming an Euler angle difference and treating it as an exact rotation
vector.
\end{enumerate}

\section{What comes next}

Q13 develops numerical quaternion propagation.  It compares direct numerical
integration of quaternion kinematics with exponential updates from sampled gyro
increments, discusses normalization drift, and treats quaternion sign
continuity in discrete time.

\section{Sources and historical notes}

Quaternion attitude error measures are standard in spacecraft estimation and
control.  Bach and Paielli's NASA Technical Memorandum 102798 develops a
quaternion attitude error formulation and shows how its first three components
can be used in an exact linear error control construction.  The equations in
this article are written in the PhysicsLibrary convention rather than copied
from that report because error multiplication order and coordinate meaning are
convention dependent.  The small rotation vector interpretation is also
consistent with standard multiplicative attitude estimation practice.

\begin{thebibliography}{9}

\bibitem{BachPaielli1990}
R. Bach and R. Paielli,
\emph{Direct Inversion of Rigid-Body Rotational Dynamics},
NASA Technical Memorandum 102798, 1990.

\bibitem{Shuster1993}
M. D. Shuster,
``A Survey of Attitude Representations,''
\emph{The Journal of the Astronautical Sciences}, vol. 41, no. 4,
pp. 439--517, 1993.

\end{thebibliography}

\section*{License}

This article is an original synthesis prepared for PhysicsLibrary and intended
for release under CC BY-SA 4.0.</content>
</record>
