Main Content

quat2dcm

Convert quaternion to direction cosine matrix

Description

example

dcm = quat2dcm(q) calculates the direction cosine matrix, n, for a given quaternion, q. The quaternion input and resulting direction cosine matrix represent a right-hand passive transformation from frame A to frame B.

Aerospace Toolbox uses quaternions that are defined using the scalar-first convention. This function normalizes all quaternion inputs.

Examples

collapse all

Determine the direction cosine matrix from the single quaternion q = [1 0 1 0].

dcm = quat2dcm([1 0 1 0])
dcm = 3×3

         0         0   -1.0000
         0    1.0000         0
    1.0000         0         0

Determine the direction cosine matrices from multiple quaternions.

q = [1 0 1 0; 1 0.5 0.3 0.1]; 
dcm = quat2dcm(q)
dcm = 
dcm(:,:,1) =

         0         0   -1.0000
         0    1.0000         0
    1.0000         0         0


dcm(:,:,2) =

    0.8519    0.3704   -0.3704
    0.0741    0.6148    0.7852
    0.5185   -0.6963    0.4963

Input Arguments

collapse all

Quaternion, specified as an m-by-4 matrix containing m quaternions. Each element of q must be a real number.

Data Types: double

Output Arguments

collapse all

Direction cosine matrices, returned as a 3-by-3-by-m matrix, where m is the number of direction cosine matrices. The direction cosine matrix performs the coordinate transformation of a vector in inertial axes to a vector in body axes.

Version History

Introduced in R2006b