quaternion
Create quaternion array
Description
A quaternion is a four-part hyper-complex number used in three-dimensional rotations and orientations.
A quaternion number is represented in the form , where a, b, c, and d parts are real numbers, and i, j, and k are the basis elements, satisfying the equation: i2 = j2 = k2 = ijk = −1.
The set of quaternions, denoted by H, is defined within a four-dimensional vector space over the real numbers, R4. Every element of H has a unique representation based on a linear combination of the basis elements, i, j, and k.
All rotations in 3-D can be described by an axis of rotation and angle about that axis. An advantage of quaternions over rotation matrices is that the axis and angle of rotation is easy to interpret. For example, consider a point in R3. To rotate the point, you define an axis of rotation and an angle of rotation.
The quaternion representation of the rotation may be expressed as , where θ is the angle of rotation and [ub, uc, and ud] is the axis of rotation.
Creation
Syntax
Description
creates an empty
quaternion.quat
= quaternion()
creates a quaternion array where the four quaternion parts are taken from the
arrays quat
= quaternion(A,B,C,D
)A
, B
, C
, and
D
. All the inputs must have the same size and be of the
same data type.
creates an N-by-1 quaternion array from an
N-by-4 matrix, where each column becomes one part of the
quaternion.quat
= quaternion(matrix
)
creates an N-by-1 quaternion array from an
N-by-3 matrix of rotation vectors,
quat
= quaternion(RV
,"rotvec")RV
. Each row of RV
represents a
rotation vector in radians.
creates an N-by-1 quaternion array from an
N-by-3 matrix of rotation vectors,
quat
= quaternion(RV
,"rotvecd")RV
. Each row of RV
represents a
rotation vector in degrees.
creates a quaternion array from the SE(3) transformation
quat
= quaternion(transformation
)transformation
.
creates an quaternion array from the SO(3) rotation
quat
= quaternion(rotation
)rotation
.