Code covered by the BSD License  

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 9 ratings Rate this file 130 Downloads (last 30 days) File Size: 142 KB File ID: #33341 Version: 1.7
image thumbnail




18 Oct 2011 (Updated )

quaternion class, vectorized, converts among rotation representations, numerical Euler propagation

| Watch this File

File Information

quaternion.m is a matlab class that implements quaternion mathematical operations, 3 dimensional rotations, transformations of rotations among several representations, and numerical propagation of Euler’s equations for rotational motion. All quaternion.m class methods except PropagateEulerEq are fully vectorized.


Function To Convert Between Dcm, Euler Angles, Quaternions, And Euler Vectors inspired this file.

Required Products MATLAB
MATLAB release MATLAB 8.2 (R2013b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
30 Jun 2015 Matthew

Good idea, well executed. Also
Good pdf documentation provided.

Nit-picking: MATLAB help documentation could be much improved. Test could be put into unit-test framework.

15 Apr 2015 Matthew Anderson

Excellent code -- had one issue thus far, see example:

aa = zeros(3,3,2);
aa(:,:,1) = RotationMatrix(quaternion.rand);
aa(:,:,2) = RotationMatrix(quaternion.rand);

Warning: repmat(A,M) or repmat(A,M,N) where M or N is an empty array will return an error in a
future release. Replace empty array inputs with 1 instead.
> In quaternion>quaternion.normalize at 983
In quaternion>quaternion.rotationmatrix at 2092
In quaternion>quaternion.normalize at 983
In quaternion>quaternion.rotationmatrix at 2092

I think the fix is simply to make nel = 1, when isempty(nel) is true before calling the repmat.

Comment only
15 Apr 2015 Matthew Anderson  
16 Aug 2014 Amy

Amy (view profile)

I'd like to commend you for a powerful set of scripts. I learned a lot by running the demo and changing the parameters. Great contribution.
Is there a way for me to use your code to simulate a wobbling rigid body? I think about the out-of-balance case like an unbalanced tire rotating in space.

04 Jul 2014 Rody Oldenhuis

Rody Oldenhuis (view profile)

09 Apr 2014 spencer

spencer (view profile)

Are the euler angles defined as "body-fixed" or "world-fixed"?

Comment only
29 Oct 2013 Windo

Windo (view profile)

This is great stuff. Concise and functional. However, I have a problem with function 'unitvector'. It is used in several places in the code but it is nowhere to be seen. Here's an example error message when trying to use 'OmegaAxis':

1492 [axis, omega] = unitvector( omegav, 1 );
Undefined function 'unitvector' for input arguments of type 'double'.

Error in quaternion/OmegaAxis (line 1492)
[axis, omega] = unitvector( omegav, 1 );

25 Jul 2013 Felix

Felix (view profile)

Thank you for your nice work.

When i use the function "interp1", MATLAB warns the function "isrow" undefined. Is this a bug?

11 Jul 2013 Nicolas

Super great ! Thanks a lot

21 Feb 2013 Alessandro

nice work

05 Feb 2013 Ted Shultz

This is a nice full featured quaternion class with excellent documentation and clean code.

Comment only
05 Feb 2013 Ted Shultz  
29 Dec 2011 1.1

fixed bugs, added some new methods

18 May 2012 1.2

A few new methods and small bug fixes

13 Nov 2012 1.3

added quaternion.OmegaAxis to get angular velocity vectors from time series of quaternions

16 Jan 2013 1.5

change normalize, rand; fix isequal*, rotateutov; add dot, interp1, randRot

22 Nov 2013 1.6

Added missing unitvector function for OmegaAxis method

26 Jun 2015 1.7

Changes: revised error messages, corrected repmat syntax
New methods: ComplexMatrix, complexmatrix, integrateomega, Integral, ModifiedRodrigues, modifiedrodrigues, Rodrigues, rodrigues, RotateTensor

Contact us