Main Content

Angular distance in radians

returns the angular distance in radians between two quaternions,
`distance`

= dist(`quatA,quatB`

)`quatA`

and `quatB`

.

The `dist`

function returns the angular distance between two
quaternions.

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 the
angle of *q* as $${\theta}_{q}=2{\mathrm{cos}}^{-1}(a)$$.

Consider two quaternions, *p* and *q*, and the
product $$z=p*\text{conjugate}(q)$$. As *p* approaches *q*, the angle of
*z* goes to 0, and *z* 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, the angular distance is
calculated
as:

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