Quaternion Library for Simulink

A library of blocks for manipulating quaternions.
4.6K Downloads
Updated 12 Dec 2009

View License

Quaternion Library for Simulink
Version 1.7 (JASP) 12-Dec-2009

This is a library of blocks that allows manipulation of quaternions.

The available blocks are:

Quaternion Normalize
Quaternion Conjugate
Quaternion Multiply

Quaternion Propagation
Quaternion Vector Transform
Quaternion Vector Rotation

Quaternion Decomposition
Quaternion to DCM
DCM to Quaternion

Row Major to Matrix
Matrix to Row Major

For purposes of this library, a quaternion, q, is just a four element vector where q(1:3) is the "imaginary" or "vector" portion of the hypercomplex number, and q(4) is the "real" or "scalar" portion. Consequently, if q represents a rotation, then:

q(1) = v1*sin(phi/2)
q(2) = v2*sin(phi/2)
q(3) = v3*sin(phi/2)
q(4) = cos(phi/2)

where phi is the amount of rotation about the unit vector [v1 v2 v3].

The DCM's produced by the "Quaternion to DCM" block and used by the DCM to Quaternion block are written in row major form instead of normal MATLAB matrices. Back when this library was first developed, Simulink signals could not be matrices, so were written in the C-friendly row-major format. To prevent the breakage of models that were written to use the row major signals, the interface to the blocks have not been changed but two blocks were added to aid with the translation of matrices to/from row major format.

IMPORTANT NOTE: For purposes of quaternion/DCM equivalence, the relationship is chosen to be:

R v = q* v q

Therefore a "transform" is (q* v q) and a "rotation" is (q v q*). This follows the convention used in "Spacecraft Attitude Determination and Control", edited by James R. Wertz, Copyright 1978. Note that many recent uses of quaternions choose the opposite convention (the "left" quaternion being the equivalent), including many computer graphics libraries.

See also QUATERNIONS, the quaternion manipulation toolbox for the MATLAB command line. RM2MAT and MAT2RM functions provided by the Matrix Library for Simulink are also useful for handling row-major form matrices.

Cite As

Jay St. Pierre (2024). Quaternion Library for Simulink (https://www.mathworks.com/matlabcentral/fileexchange/259-quaternion-library-for-simulink), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

* Changed mux to bus creator blocks where appropriate.

* Added "Row Major to Matrix" and "Matrix to Row Major" blocks to aid with interfacing with the matrix signals now available in Simulink.

1.1.0.0

Changed license from GPL to BSD

1.0.0.0