Euler Angles vs. Axis Angle

Hello,
I am really confused regarding transformations and I hope someone could help me:

I cannot understand what is the difference between Euler angles and axis angle, I mean I know they are two different kind of way to represent orientation, but it’s not clear to me why is preferable to use axis angle. In fact even if i understand that the sum of two different euler angles give a different result from the matrix multiplication
it seems to me i get exactly the same using the axis angle:

glRotated(-90,1,0,0); + glRotated(90,0,1,0); + glRotated(90,1,0,0);

doesn’t give as result a vector (90,0,1,0).

Euler Angles, Axis+Angle, Quaternions, Rotors, et al. are all equiv. as an ‘end-result’…specifically they all can represent a rotation. The difference is memory size, speed of evaluation and ease of implimentation of various operations on the representation.

I may be wrong but I see that like this :

  • When you speak about of a rotation around Axis, it is a rotation around an world Axis.
  • When you speak about Euler angle, the rotations are around the successive local Axis.

In you example, glRotated(-90,1,0,0); + glRotated(90,0,1,0); + glRotated(90,1,0,0);" (you do not sum them, but you multiply them), the second and third rotation are around local X and Y axis and not around world X and Y Axis. Of course, it will not give you the rotation that you expect.

In my opinion, Euler angle are good for simple initial setup rotation. But don’t deal with them after. Keep rotations in a matrix or use quaternion for interpolation. (Well I don’t now what is the best to use if you want to deal with physics)

The different representations can suffer from problems when concatenating multiple rotations together. Look into “gimbal lock” with euler angles and it should help explain.

“gimbal lock” results of a misundertand that euler angles are three successive world space rotation and that they should be used to set an object in one pos not to animate it.

Usually you will set an objet in world space using euler rotations + one translation like :
rotateX(rx),rotateY(ry),rotatZ(rz) or as you said glRotated(-90,1,0,0); + glRotated(90,0,1,0); + glRotated(90,1,0,0);

but ususally you will not increase or decrease one of your euler angle to rotate your object because increasing one euler angle doesn’t always means to rotate around the corresponding axis.

=> like increasing RY doesn’t mean you rotate around local axis Y but rather around world axis Y

this is the same for the translation increasing TZ move along Z world axis not Z local axis, and for example to move an object forward (along its Z axis) you will have to use its local axis, not its Z translation, the same apply for rotations.

so for example you can set an objet in any world pos using two ops (used a lot by 3d software studios):
rotate(rx,ry,rz)
translate(px,py,pz)

but you will ususally not directly modify any of thoses 6 values rx,ry,rz,px,py,pz (cause they dont represent something really logical as you would expect) but rather you will use object local axis to rotate or translate this object.

if you want to rotate or move the object around its axis you have to compute its local axis on world :
O(0,0,0);
AX(1,0,0);
AY(0,1,0);
AZ(0,0,1);

O.translate(px,py,pz)
AX.rotate(rx,ry,rz)
AX.translate(px,py,pz)
AY.rotate(rx,ry,rz)
AY.translate(px,py,pz)
AZ.rotate(rx,ry,rz)
AZ.translate(px,py,pz)

//here you can rotate around local axis by rotating around AX, AY or AZ
//or move using AX-O,AY-O,AZ-O

so in conclusion usually :
=> euler is used to set an objet in one pos / store its pos
=> axis to “animate” rotate around any axis

Without knowing exactly what you’re trying to do, it’s hard to give specific advice, other than to read up on the Wikipedia entries and start following links until you “get it” - http://en.wikipedia.org/wiki/Axis_angle and http://en.wikipedia.org/wiki/Euler_angles would be the places to start.

The one piece of advice I’ll definitely offer is that there are a lot of pros to using quaternions for rotations (http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation). The problems that both Euler and axis angle representations suffer from all come from the fact that there’s no way for a 3 dimensional set to “nicely” parameterize the group of rotations (the aforementioned gimbal lock problem, which fundamentally owes to the fact that you can’t comb hair flat against a hairy tennis ball so that it smoothly varies), and the only full solution is to add a fourth degree of freedom and a corresponding constraint (with quaternions, this is the normalization constraint - you can do the same thing with matrices, but matrices have 9 DOF instead of just 4, so it takes a bit more computation; if you think about the tennis ball problem, it’s somewhat akin to removing the requirement that we have to comb the hair flat).

If you want to dive deeper into madness, Google for David Hestenes and his thoughts on geometric calculus/algebra (dealing with Clifford algebras, basically) - to some extent it turns out that the real problem with vectors is that they only represent a particular slice of the true geometric content available, and in 3 dimensions we only get away with the vector approach because 2-forms are dual to vectors (eh…if that doesn’t make sense, don’t worry about it :slight_smile: ), but that comes at a significant cost to simplicity (which is why we end up with such hideous contraptions as the cross product, a bastard vector-like-thingy that doesn’t transform correctly under coordinate transformations - try it, see what happens when you add a “-1” to all the real vectors in your space, and then look at the cross products!).

I’m getting off topic, though, so I’ll leave it at that - I suppose it’s probably obvious that I’m a big math weenie…

Yes it is right. As I already wrote in the past, gimbal lock can be avoided only by using non eulerian transforms (they are easier to express with quaternions), it has been proved by Pr. Pascal Mignot of the University of Reims, France.

[quote]glRotated(-90,1,0,0); + glRotated(90,0,1,0); + glRotated(90,1,0,0);

doesn’t give as result a vector (90,0,1,0).
[/quote]
each euler angle are just a specific case of axis

NB: axis rotation work just like quaternion

Thank you everyone for the reply and I have some other questions:

  • I understand that rotating objects using glRotated() means rotate them around the world axis, and this is bad because you lose control of it. But glRotated is an Axis-Angle or is an Euler Angle?

  • I glRotated() is an Euler Angle how can i perform an axis angle rotation in order to rotated the object around it’s local axis?

  • Please could you write me down the code ( in OpenGL) that give me the gimbal lock? i think that only when I will see it happening i will really understand what is it…

  • and last thing please could you tell me what do you mean with this:
    O(0,0,0);
    AX(1,0,0);
    AY(0,1,0);
    AZ(0,0,1);

O.translate(px,py,pz)
AX.rotate(rx,ry,rz)
AX.translate(px,py,pz)
AY.rotate(rx,ry,rz)
AY.translate(px,py,pz)
AZ.rotate(rx,ry,rz)
AZ.translate(px,py,pz).

By the way i read lot of times yesterday wiki etc and it confused me even more… i will go through it again again but i want really understand this topic…

Thanks

[quote] I glRotated() is an Euler Angle how can i perform an axis angle rotation in order to rotated the object around it’s local axis?
[/quote]
glrotate(a,vx,vy,vz) is an axis rotation but glRotated(a,1,0,0) is one of the three euler rotation

[quote]- Please could you write me down the code ( in OpenGL) that give me the gimbal lock? i think that only when I will see it happening i will really understand what is it…
[/quote]
gimbal locks is only a “real life problem”

[quote]- and last thing please could you tell me what do you mean with this:
O(0,0,0);
AX(1,0,0);
AY(0,1,0);
AZ(0,0,1);

O.translate(px,py,pz)
AX.rotate(rx,ry,rz)
AX.translate(px,py,pz)
AY.rotate(rx,ry,rz)
AY.translate(px,py,pz)
AZ.rotate(rx,ry,rz)
AZ.translate(px,py,pz).

By the way i read lot of times yesterday wiki etc and it confused me even more… i will go through it again again but i want really understand this topic…
[/quote]
see image below

I don’t know that I’d call it a real life problem only - if you have a set of equations (say, physical equations) that you’re using, gimbal lock means that these equations to get all screwy at certain points in rotation space because the degrees of freedom degenerate as two rotation axes align. If one of your bodies moves into one of these positions, everything is going to explode on you as you try to calculate the next step, and that’s a quite practical concern in a game.

To make it more concrete, when you write down equations of motion using Euler angles, some of the equations involve dividing by a cosine of an angle. If that’s zero, you’re screwed, and as it gets closer to zero you’re likely to get crap answers due to the fact that you don’t have infinite precision/infinitesimal time step.

Your previous comment was dead on, IMO - Euler angles are perfectly valid ways to specify rotations (i.e. it’s a valid coordinate system), but when you try to do anything to those rotations you run into trouble. Things like animation and physics are not well suited for Euler angles, but for scene construction they work just fine because you just need to position things, not move them.

[quote] don’t know that I’d call it a real life problem only - if you have a set of equations (say, physical equations) that you’re using, gimbal lock means that these equations to get all screwy at certain points in rotation space
[/quote]
I mean Gimbal locks is when you have turned such than one of your object local Axis lie on a World Axis (different)… and as you are doing world rotation you just get surprise that turning around this axis just result in turning around the same local axis… but that’s only logic ! there is nothing wrong with it and there is no problem… but in real life Gimbal locks is real like if you use a Compas in a plane but the plane go straight UP => compas get lost. so what I mean is that if you use world axis but have in mind / thinking that you are using local axis the logic is wrong.

like if you have a ball in a physic computation : a force that push to rotate around X and another force that push to rotate around Y, if you are trying to combine World rotation RX/RY this is at the base wrong because once the ball will have started to rotated even with an epsilon degree the whole equation get wrong, but that’ logical because you started with bad equation/suposition.

[quote]but when you try to do anything to those rotations you run into trouble.
[/quote]
yes inded because “they do not have a direct human sens but they seems to have”

also I mean that

[quote]the degrees of freedom degenerate as two rotation axes align
[/quote]
is absolutly impossible… only two axis from differents spaces can align but two axis in the same space will never align they are unbreakable and stay orthogonal/perpendicular

@DzzD
I’d semi ignore the ‘gimbal lock’ point. As you point you it only an issue when attempting to animate and animating a rotation/orientation in directly in Euler angles is too much work (human and computer). WRT to Euler angles I’d simply say that IHMO they have no utility as an internal representation. Sure there are some NA methods that work well with Euler angle representations, but that’s about it…and one can simply convert into if needed. But that’s simply my opinion (shrug).

@ewjordan
combing hair = “hairy ball thereom” (for others if curious) - says that embedding in an even number of dimensions is required. Easy to see in 2D…choose a direction to move around the circle.

To be anal: Quaternions and 3x3 matrices require 4 & 9 elements respectively, but both only have 3 DOF. (assuming unit quaternions and the matrix represents only an unscaled rotation)

GA: Some other names for searches: Chris Doran, Leo Dorst, Christan Perwass, Daniel Fontijne, Alan Macdonald. Other than papers I’d also look at the following programs: CLUCalc & gaviewer.

Actually it’s possible, but if physics is not envolved you can recover from that situation.
For example if you are using a configuration ZXZ :

glRotate(z , 0, 0, 1)
glRotate(x , 1, 0, 0)
glRotate(z1 , 0, 0, 1)

that means that you have 3 degrees of freedom, when x = 0 z is align with z1 you have the gimbal lock and you lost a degree of freedom for a configuration xyz:

glRotate(x , 1, 0, 0)
glRotate(y , 0, 1, 0)
glRotate(z , 0, 0, 1)

for y = 90 again you have the gimbal lock, that anyway doesn’t make any sense if you are not running a simulation since you can recover every time from it

[quote]Actually it’s possible, but if physics is not envolved you can recover from that situation.
[/quote]
No, No, No ,No, No NoNoNo, No No ! (better with background music…)

:’(

if you try to simulate a gimbals system… wich basically is what you do

you can then… as in “Real life”… go in a position where Gimbals are locked cause you have aligned two gimbals axis, but that’s not surprising it would be strange if it did not , no ?

keep in mind that local object axis ARE NOT like those gimbals axis they cannot move independently from each others, they cannot be breaked.

also saying that you loose a degree of freedom is a bit false :

you can still rotate in any direction by changing rx,ry,rz (but those three new rx,ry,rz are hard to compute, cannot be found easily and are not just an increase of rx,ry or rz, you see what I mean ?)… as there is something different in computer than in “real life” wich is => I can set any value rx,ry,rz at anytime… I am not forced to go from one pos to another in a linear way…

I believe we may all be arguing slightly different things; to me, losing a degree of freedom means no more than that there are areas in the space of Euler angles where (locally) a variation of three parameters can produce, at first order, only two dimensions of variation in rotation space. This means that the determinants go to zero, transformations blow up, robots start slapping themselves in the face, etc.

Put another way, the entire rotation space may be covered by the Euler angles (as you point out, we can always achieve any rotation we’d like), but the tangent space mapping has holes.