Main Content

dcm2quat

Convert direction cosine matrix to quaternion

Description

example

q= dcm2quat(dcm)calculates the quaternionqfor a given direction cosine matrix,dcm.

q= dcm2quat(dcm,action)performs an action,action, if the direction cosine matrix is invalid, that is not orthogonal.

q= dcm2quat(dcm,action,tolerance)uses a tolerance level,tolerance, to evaluate if the direction cosine matrixdcmis within tolerance.

Examples

collapse all

Determine the quaternion from a direction cosine matrix.

dcm = [0 1 0; 1 0 0; 0 0 -1]; q = dcm2quat(dcm)
q =1×40 0.7071 0.7071 0

This example shows how to determine the quaternions from multiple direction cosine matrices.

dcm = [ 0 1 0; 1 0 0; 0 0 -1]; dcm(:,:,2) = [ 0.4330 0.2500 -0.8660;...0.1768 0.9186 0.3536;...0.8839 -0.3062 0.3536]; q = dcm2quat(dcm)
q =2×40 0.7071 0.7071 0 0.8224 0.2006 0.5320 0.0223

Determine the quaternion from direction cosine matrixdcmwithin tolerance.

dcm = [0 1 0; 1 0 0; 0 0 -1]; q = dcm2quat(dcm,'Warning', 0.01)
q =1×40 0.7071 0.7071 0

Input Arguments

collapse all

Direction cosine matrix, specified as a 3-by-3-by-Mmatrix.

Data Types:double

Function behavior when direction cosine matrix is invalid, that is, not orthogonal.

  • 'Warning'— Displays warning and indicates that the direction cosine matrix is invalid.

  • 'Error'— Displays error and indicates that the direction cosine matrix is invalid.

  • 'None'— Does not display warning or error.

Data Types:char|string

Tolerance of direction cosine matrix validity, specified as a scalar. The function considers the direction cosine matrix valid if these conditions are true:

  • The transpose of the direction cosine matrix times itself equals1within the specified tolerance (transpose(dcm)*dcm == 1±tolerance).

  • The determinant of the direction cosine matrix equals1within the specified tolerance (det(dcm) == 1±tolerance).

Data Types:double

Output Arguments

collapse all

Quaternion, returned in anm-by-4 matrix.qhas a scalar number as the first column.

版本历史

Introduced in R2006b