logo back up home forward   further reading more topics »

Maths - Affine Conversion - Matrix to Euler/Vector

Definition of terms:

It you want to consider the rotation only then the code for this is shown here.

Alternatively if we want to consider the possibility that there is also a translation from the centre, and that the rotation may not be about the centre but may be about some arbitrary point, then we need to extend the notation as follows:

 

This conversion is better avoided, since it is non-linier and has singularities at + & - 90 degrees, so if already working in terms of matricies its better to continue using matrices if possible.

This depends on what conventions are used for the Euler Angles. See this page for the conventions and standards used on this site.

So it we look at the Euler to Matrix conversion we can see that:


m01/m00 = s1 / c1 = tan(heading)
m12/m22 = s3 / c3 = tan(bank)
m02 = -s2 = -sin(attitude)

so this gives:

heading = atan(m01/m00)
bank = atan(m12/m22)
attitude = asin(-m02)

Note this only applies to a martix which represents a pure rotation. The equations for heading and bank should be independent of uniform scaling as it will cancel out in the division. It would be better to find an expression for attitude which is also independent of scaling.

Since there are several ways to produce the same rotation using heading, bank and attitude then the solution is not unique. tan(0) is 0, tan(90 degrees) is infinity, tan(-90 degrees) is -infinity. So the results will depend on whether arctan processes a result between -90 and 90 or 0 and 180.

 

 

 

 

 

 

 

 

 

 

 


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

 

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to the software project, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

Can you help?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

http://sourceforge.net/projects/mjbworld/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.