Maths - Conversion Quaternion to Euler - Forum

By: Andy Goldstein - andygoldstein
file Corrections for Euler angles page et al  
2004-01-18 01:43

Martin, I've worked through the Euler angle and quaternion pages, and the related transformations in detail, and I have some major corrections for the Euler angles page. I also have detailed derivations for some of the Euler/quaternion transformations. All this is written up as a Word document with liberal use of the equation editor. What's the best way to get this to you?

Cheers - Andy

By: Martin Baker - martinbaker
file RE: Corrections for Euler angles page et al  
2004-01-18 09:18

Andy,

Thank you very much.

I will update the pages when I get it, is it also OK to include your document on the site?

The latest version of word that I have is word2000, if you are using a later version I might not be able to read it, in this case would it be possible to export to HTML for me (this converts equations to gifs).

Thanks,

Martin

By: Michaele Norel - minorlogic
file RE: Corrections for Euler angles page et al  
2004-03-31 15:53

Hi Martin !

on this page
https://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm

When you convert quat to euler
heading = Math.atan2(2.0 * (q1.x*q1.y + q1.z*q1.w),(sqx - sqy - sqz + sqw));
bank = Math.atan2(2.0 * (q1.y*q1.z + q1.x*q1.w),(-sqx - sqy + sqz + sqw));

the "heading" and "bank" will be found correctly for for unit and nonunit quaternions too.

The use asin - is not good choice at all. You can swith the "attitude" in to atan2 , if you place there the
atan2( sin_attitude, cos_attitude );

just you need to find cos_attitude ( as i remember this can be found using one sqrt call)

And than your code will take a nonunit quaternions too, with comparable speed.

By: Martin Baker - martinbaker
file RE: Corrections for Euler angles page et al  
2004-04-01 01:28

Hi minorlogic,

Yes, it would be very good to remove any requirement for a unit quaternion as input.

How do we check whether this is true? I guess that if we have:

k*x , k*y , k*z , k*w

where k=constant scaling factor.

Then if k cancels out in the equations then there is no requirement for unit quaternion? I can see that this applies to the expressions for heading and bank but not the expression for attitude.

But if we are using tan(a) = sin(a)/cos(a) how can we cancel out any constant scaling factor? I cant work out how to do this?

Martin

By: Andy Goldstein - andygoldstein
file RE: Corrections for Euler angles page et al  
2004-04-02 08:30

Well, there's a fundamental problem here. For the two angles that are computed as ATANs, k cancels out because we're dividing one set of terms from the quaternion by another. That's a happy coincidence in the rotation matrix you get from Euler angles (in https://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm .

However, for the remaining angle (theta in our current discussion) there are no terms in the matrix that lend themselves to solving for theta using a division. The only tractable term is the sin (theta) term; I don't see how you can solve for theta using some of the more complex terms that contain both sin (theta) and cosine (theta).

Normalizing a quaternion is straightforward enough: you simply divide each component of the quaternion by sqrt (w**2 + x**2 + y**2 + z**2),

- Andy

By: Andy Goldstein - andygoldstein
file RE: Corrections for Euler angles page et al  
2004-04-02 10:22

After another 10 minutes thought...

If we combine the normalization of the quaternion into the expression for theta, we can save a sqrt operation, since the numerator term contains products of two quaternion components. So if for a normalized quaternion, theta = asin (2wy - 2xz), then for an unnormalized quaternion,

theta = asin ((2wy - 2xz) / (ww + xx + yy + zz))

In terms of complexity, this is consistent with the atan expressions for the other two angles.

- Andy

By: Martin Baker - martinbaker
file RE: Corrections for Euler angles page et al  
2004-04-02 23:06

Andy,

That's brilliant; a well spent 10 minutes in my opinion.

I've included this on the webpage.

Martin


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.

cover If you are interested in 3D games, this looks like a good book to have on the shelf. If, like me, you want to have know the theory and how it is derived then there is a lot for you here. Including - Graphics pipeline, scenegraph, picking, collision detection, bezier curves, surfaces, key frame animation, level of detail, terrain, quadtrees & octtrees, special effects, numerical methods. Includes CDROM with code.

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

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