Maths - e-mail Subject: Euler to Quaternion

From: "Mark Elson"
To: "Martin.Baker"
Subject: Euler to Quaternion
Date: 18 December 2002 16:11

Hi Martin,

Great web-site.

I'm not sure that one set of formulae is correct for the Euler to
Quaternion conversion though

On
https://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm

You have

w = e0 = c1c2c3 + s1s2s3
x = e1 = c1c2s3 - s1s2c3
y = e2 = c1s2c3 + s1c2s3
z = e3 = s1c2c3 - c1s2s3

Where c1 = cos(heading) etc.

I believe this should be c1 = cos(0.5*heading) and so on for the rest.

I haven't been through William's proof yet and I'm struggling to find a
definitive reference without working it out myself (I had a ref from a
web-site but the link has expired -
http://www.rust.net/~kgeoinfo/quaternion.txt). If I do find something
I'll let you know though.

When I implement code as per your web-page I get double the rotation I
expect. This is correct using half-angles in place of the Euler angles

BTW, when I implemented code exactly as per Wolframs page
http://mathworld.wolfram.com/EulerParameters.html

I get wrong answers interestingly enough.

Best Regards,

Mark


From: "Martin.Baker"
To: "Mark Elson"
Subject: Re: Euler to Quaternion
Date: 18 December 2002 18:56

Hi Mark,

Yes, I think you are right, looking at William's proof he has used lower
case (c1) to denote the cosine of angle/2 and upper case (C1) to denote
cosine of angle without dividing by 2.

Therefore I have changed the web page to show that in the formulae at the
top then the angles are divided by 2. In the code snippet the angles are not
divided by two. William's proof shows these are equivalent.

Please could I include your message on the site to warn others that there is
an issue. Please do let me know what you find, if you do work it out
yourself from first principles I would very much like to include that on the
site.

I haven't checked Wolframs page yet, I suspect they may be using a different
set of euler angles. It is a real nightmare not having a standard definition
for euler angles.

Thanks for letting me know about this,

Martin


From: "Mark Elson"
To: "'Martin.Baker'"
Subject: RE: Euler to Quaternion
Date: 19 December 2002 09:34

Hi Martin,

Please feel free to use the message.

I think you are right about Wolframs' Euler definition although I
haven't had time yet to track down the differences - at first sight I
thought they were the same as mine - a heading, attitude, bank sequence.

BTW, in your program do you rotate vectors via a Direction Cosine (or
rotation) matrix. I found a nifty algorithm for doing this directly from
the quaternion (rather than populating the DCM from the quaternion
first). It seems quicker and uses less memory. I got it from Dynamics of
Systems and Rigid Bodies by J. Wittenburg

(referred to by in the MADYMO theory manual). It goes like this:

Split quaternion into scalar, q0, and vector q then given vector r' - to
get rotated vector r

r = r' + 2.qX(qXr') 2.q0.qXr'

Or a code example

   ///Refer to:
/// Dynamics of Systems of Rigid Bodies, J Wittenburg, 1977, B.G.
   Teubner, Stuttgart 
blitz::TinyVector<double, 3> AxisRotation::rotate(const
   blitz::TinyVector<double, 3>& vector) const
   {
   blitz::TinyVector<double,3> q;
  	for (int i=1;i<4;i++ ) q[i-1] = quaternion_[i];
  	long double q0 = quaternion_[0];
   	blitz::TinyVector<double,3> q_cross_v, result;
   	q_cross_v = cross(q, vector);
   	result = vector + 2.*cross(q, q_cross_v) + 2.*q0*q_cross_v;
   	return result;
}

(yes I know I should typedef the blitz::TinyVectors :) ).

HTH

Mark


From: "Mark Elson"
To: "'Martin.Baker'"
Subject: RE: Euler to Quaternion
Date: 19 December 2002 14:11

Hi Martin,

Turns out a reference is on the Mathworks site at

http://www.mathworks.com/access/helpdesk/help/toolbox/aeroblks/euleranglestoquaternions.shtml

This shows the angles being divided by 2.

On another point with regard to the quaternion to euler conversion on

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

I have found, in C++ and Excel, anyway that the atan2(x,y) works better
than atan(x/y) when attitude is greater than 90.

With atan if you put an attitude of 100deg in you get an attitude of
80deg (correct) but will heading and bank at zero (wrong).
Atan2 switches the heading and bank to 180 deg when attitude > 90deg
which is correct.

HTH

Mark


From: Martin Baker
Sent: 19 December 2002 17:58
To: Mark Elson
Subject: Re: Euler to Quaternion


Hi Mark,

Thanks very much, I have changed both the Euler to Quaternion and
Quaternion to Euler pages to show the issues that you raised. I think it
makes them much clearer and more accurate.

My program currently uses 4x4 matrix to do the rotations and
translations, but I am thinking about how best to implement dynamics
where an object would have a state consisting of position, orientation,
linear and angular velocity. I think the orientation, at least, would be
held as a quaternion. So the algorithm may come in handy.

BTW does the Wittenburg book derive a generalised set of equations for
rigid body dynamics, if so, it may be just what I need. Looks like it is
out of print at the moment, do you think it would be worth me getting a
copy? or have you come across anything better?

Martin


From: "Mark Elson"
To: "'Martin Baker'"
Subject: RE: Euler to Quaternion
Date: 19 December 2002 19:43

Hi Martin

The Wittenburg book is not bad and was the best I could find a few years
ago - I don't know if there is anything better now. I don't know if
there is a newsgroup dealing with multi-body dynamics - if there were
they might have some recommendations.

I think the equations are pretty much in Wittenburg although it is
frequently short on explanations and derivations. It covers an iterative
approach for solving the equations in a tree-like structure - navigating
up and down the tree each time step. It covers various constraints like
hinges, sliders etc.

I haven't got as far as linking multi-bodies together. Most of my stuff
is trajectory sims of discrete 6-dof bodies like ejection seats (for a
company named very similarly to you, coincidently - they just added a
hyphen, see www.martin-baker.com).

I've almost abandoned doing this as we need validated dummy (as in crash
test) models which really only exist in MADYMO and LS-Dyna and the like.
I expect I will have a live interface to one of these so they handle the
dummy/human modeling and my code handles the gross accelerations, rocket
models etc.

I'll keep an ear out for any good books - I'll see if the TNO guys know
although they did use Wittenburg.

Cheers,

Mark


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 us uk de jp fr ca Quaternions and Rotation Sequences.

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

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