4.5

4.5 | 2 ratings Rate this file 20 Downloads (last 30 days) File Size: 66.89 KB File ID: #259
image thumbnail

Quaternion Library for Simulink

by Jay St. Pierre

 

06 Dec 2000 (Updated 12 Dec 2009)

A library of blocks for manipulating quaternions.

| Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.5 (R2007b)
Other requirements If you want to run the unit tests, you will need the test_tools package found elsewhere in this archive.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
02 Aug 2004 john burken

Works well for my quat. probles.
JJB

20 Nov 2009 Alan Bindemann

Overall a nice package. However, I found several issues with the DCM to quaternion block. The block is not designed to accept a [3x3] signal dimension, rather, it expects a 9 element vector. Also, if one uses a reshape on a [3x3] vector to recast is as the 9 element vector one needs to transpose the [3x3] first since the 9 element vector is unpacked in row order, rather than the Simulink standard of column order.

Also, the quaternion to DCM block outputs the DCM in row-order, which requires a reshape and transpose to recast as a usable [3x3] signal.

Also several of the blocks use Mux blocks as bus creators improperly which will generate errors if strict bus modeling is enabled.

Please login to add a comment or rating.
Updates
14 Dec 2001

- Block mask updates for Simulink 4.0 compatibility.
- Description typos fixed.
- Unit test warnings if test_tools not available.

07 Jan 2002

Add reference to the Quaternion Toolbox in description.

26 Jul 2009

Changed license from GPL to BSD

12 Dec 2009

* 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.

Tag Activity for this File
Tag Applied By Date/Time
simulink Jay St. Pierre 22 Oct 2008 06:34:45
quaternion Jay St. Pierre 22 Oct 2008 06:34:45
quaternions Jay St. Pierre 22 Oct 2008 06:34:45
utilities Jay St. Pierre 22 Oct 2008 06:34:45
library Jay St. Pierre 22 Oct 2008 06:34:45
block Jay St. Pierre 22 Oct 2008 06:34:45
aerospace Jay St. Pierre 27 Jul 2009 10:18:01

Contact us at files@mathworks.com