Quaternion Library for Simulink
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 (2025). Quaternion Library for Simulink (https://www.mathworks.com/matlabcentral/fileexchange/259-quaternion-library-for-simulink), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Robotics and Autonomous Systems > Robotics System Toolbox > Coordinate Transformations >
- Simulink > Simulink Environment Fundamentals > Block Libraries >
- Aerospace and Defense > Aerospace Toolbox > Standard Workflow Procedures > Coordinate Systems > Quaternion Math >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
qlib/
qlib/test/
qlib/
qlib/test/
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 |