Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Angular distance in radians

`distance = dist(quatA,quatB)`

returns the angular distance in radians between the quaternion rotation operators
for `distance`

= dist(`quatA,quatB`

)`quatA`

and `quatB`

.

The `dist`

function returns the angular distance between two
quaternion rotation operators.

A quaternion may be defined by an axis (*u _{b}*,

Given a quaternion in the form, $$q=a+b\text{i}+c\text{j}+d\text{k}$$, where *a* is the real part, you can solve for
*θ _{q}*: $${\theta}_{q}=2{\mathrm{cos}}^{-1}(a)$$.

Consider two quaternions, *p* and *q*, and the
product $$z=p*\text{conjugate}(q)$$. In a rotation operator, *z* rotates by
*p* and derotates by *q*. As *p*
approaches *q*, the angle of *z* goes to 0, and the
product approaches the unit quaternion.

The angular distance between two quaternions can be expressed as $${\theta}_{\text{z}}=2{\mathrm{cos}}^{-1}\left(\text{real}\left(z\right)\right)$$.

Using the `quaternion`

data type syntax, angular distance is calculated
as:

angularDistance = 2*acos(parts(p*conj(q)));