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.

Convert quaternion to rotation vector (degrees)

`rotationVector = rotvecd(quat)`

converts the quaternion array, `rotationVector`

= rotvecd(`quat`

)`quat`

, to an
*N*-by-3 matrix of equivalent rotation vectors in degrees. The
elements of `quat`

are normalized before conversion.

All rotations in 3-D can be represented by four elements: a three-element axis of rotation and a rotation angle. If the rotation axis is constrained to be unit length, the rotation angle can be distributed over the vector elements to reduce the representation to three elements.

Recall that a quaternion can be represented in axis-angle form

$$q=\mathrm{cos}\left(\raisebox{1ex}{$\theta $}\!\left/ \!\raisebox{-1ex}{$2$}\right.\right)+\mathrm{sin}\left(\raisebox{1ex}{$\theta $}\!\left/ \!\raisebox{-1ex}{$2$}\right.\right)\left(\text{xi}+y\text{j}+z\text{k}\right),$$

where *θ* is the angle of rotation in degrees, and
[*x*,*y*,*z*] represent the axis
of rotation.

Given a quaternion of the form

$$q=a+bi+cj+dk\text{\hspace{0.17em}},$$

you can solve for the rotation angle using the axis-angle form of quaternions:

$$\theta =2{\mathrm{cos}}^{-1}\left(a\right).$$

Assuming a normalized axis, you can rewrite the quaternion as a rotation vector
without loss of information by distributing *θ* over the parts
*b*, *c*, and *d*. The rotation
vector representation of *q* is

$${q}_{\text{rv}}=\frac{\theta}{\mathrm{sin}\left(\raisebox{1ex}{$\theta $}\!\left/ \!\raisebox{-1ex}{$2$}\right.\right)}[b,c,d].$$