This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

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.

rotvecd

Convert quaternion to rotation vector (degrees)

Syntax

rotationVector = rotvecd(quat)

Description

example

rotationVector = rotvecd(quat) converts the quaternion array, quat, to an N-by-3 matrix of equivalent rotation vectors in degrees. The elements of quat are normalized before conversion.

Examples

collapse all

Convert a random quaternion scalar to a rotation vector in degrees.

quat = quaternion(randn(1,4));
rotvecd(quat)
ans = 1×3

   96.6345 -119.0274   45.4312

Input Arguments

collapse all

Quaternion to convert, specified as scalar, vector, matrix, or multidimensional array of quaternions.

Data Types: quaternion

Output Arguments

collapse all

Rotation vector representation, returned as an N-by-3 matrix of rotation vectors, where each row represents the [x y z] angles of the rotation vectors in degrees. The ith row of rotationVector corresponds to the element quat(i).

The data type of the rotation vector is the same as the underlying data type of quat.

Data Types: single | double

Algorithms

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=cos(θ2)+sin(θ2)(xi+yj+zk),

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,

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

θ=2cos1(a).

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

qrv=θsin(θ2)[b,c,d].

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2018a