Orientation, Position, and Coordinate Systems

Quaternions, Euler angles, rotation matrices, and conversions

Represent orientation and rotation using the quaternion data type. Convert between quaternions and Euler angles, rotation matrices, and rotation vectors using the euler, rotmat, and rotvec functions.

To learn more about quaternion mathematics and how they are implemented in Sensor Fusion and Tracking Toolbox™, see Rotations, Orientation, and Quaternions. To learn more about conventions and coordinate systems in Sensor Fusion and Tracking Toolbox, see Orientation, Position, and Coordinate Systems.

Functions

expand all

quaternionCreate a quaternion array
onesCreate quaternion array with real parts set to one and imaginary parts set to zero
zerosCreate quaternion array with all parts set to zero
classUnderlyingClass of parts within quaternion
normalizeQuaternion normalization
randrotUniformly distributed random rotations
times, .*Element-wise quaternion multiplication
mtimes, *Quaternion multiplication
prodProduct of a quaternion array
minus, -Quaternion subtraction
uminus, -Quaternion unary minus
conjComplex conjugate of quaternion
ldivide, .\Element-wise quaternion left division
rdivide, ./Element-wise quaternion right division
expExponential of quaternion array
logNatural logarithm of quaternion array
power, .^Element-wise quaternion power
distAngular distance in radians
normQuaternion norm
meanrotQuaternion mean rotation
slerpSpherical linear interpolation
rotateframeQuaternion frame rotation
rotatepointQuaternion point rotation
ctranspose, 'Complex conjugate transpose of quaternion array
transpose, .'Transpose a quaternion array
rotmatConvert quaternion to rotation matrix
rotvecConvert quaternion to rotation vector (radians)
rotvecdConvert quaternion to rotation vector (degrees)
partsExtract quaternion parts
eulerConvert quaternion to Euler angles (radians)
eulerdConvert quaternion to Euler angles (degrees)
compactConvert quaternion array to N-by-4 matrix

Topics

Rotations, Orientation, and Quaternions

This example reviews concepts in three-dimensional rotations and how quaternions are used to describe orientation and rotations.

Lowpass Filter Orientation Using Quaternion SLERP

This example shows how to use spherical linear interpolation (SLERP) to create sequences of quaternions and lowpass filter noisy trajectories.