Main Content

Rotation Angles to Quaternions

Calculate quaternion from rotation angles

  • Rotation Angles to Quaternions block

Libraries:
Aerospace Blockset / Utilities / Axes Transformations

Description

The Rotation Angles to Quaternions block converts the rotation described by the three rotation angles (R1, R2, R3) into the four-element quaternion vector (q0, q1, q2, q3), where quaternion is defined using the scalar-first convention. Aerospace Blockset™ uses quaternions that are defined using the scalar-first convention. The rotation angles represent a series of right-hand intrinsic passive transformation from frame A to frame B. The resulting quaternion represents a right-hand passive rotation from frame A to frame B. For more information on quaternions, see Algorithms.

Limitations

  • The limitations for the ZYX, ZXY, YXZ, YZX, XYZ, and XZY implementations generate an R2 angle that is between ±90 degrees, and R1 and R3 angles that are between ±180 degrees.

  • The limitations for the ZYZ, ZXZ, YXY, YZY, XYX, and XZX implementations generate an R2 angle that is between 0 and 180 degrees, and R1 and R3 angles that are between ±180 degrees.

Ports

Input

expand all

Rotation angles, specified as a 3-by-1 vector, in radians.

Data Types: double

Output

expand all

Quaternion, specified as a 4-by-1 vector.

Data Types: double

Parameters

expand all

Specifies the rotation order for the three input rotation angles.

Programmatic Use

Block Parameter: rotationOrder
Type: character vector
Values: 'ZYX' | 'ZYZ' |'ZXY' | 'ZXZ' | 'YXZ' | 'YXY' | 'YZX' | 'YZY' | 'XYZ' | 'XYX' | 'XZY' | 'XZX'
Default: 'ZYX'

Algorithms

A quaternion vector represents a rotation about a unit vector (μx,μy,μz) through the angle θ. A unit quaternion itself has unit magnitude, and can be written in the following vector format:

q=[q0q1q2q3]=[cos(θ/2)sin(θ/2)μxsin(θ/2)μysin(θ/2)μz]

An alternative representation of a quaternion is as a complex number,

q=q0+iq1+jq2+kq3

where, for the purposes of multiplication:

i2=j2=k2=1ij=ji=kjk=kj=iki=ik=j

The benefit of representing the quaternion in this way is the ease with which the quaternion product can represent the resulting transformation after two or more rotations.

Extended Capabilities

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

Version History

Introduced in R2007b