Convert quaternion to rotation vector (degrees)
Convert Quaternion to Rotation Vector in Degrees
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
rotationVector — Rotation vector representation (degrees)
N-by-3 numeric matrix
Rotation vector representation, in degrees, returned as an
N-by-3 numeric matrix of rotation vectors, where
N is the number of quaternions in the
Each row represents the [X
Z] angles of the rotation vectors in degrees. The
ith row of
corresponds to the element
The data type of the rotation vector is the same as the underlying data
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
where θ is the angle of rotation in degrees, and [x,y,z] represent the axis of rotation.
Given a quaternion of the form
you can solve for the rotation angle using the axis-angle form of quaternions:
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
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Introduced in R2019b