Rotations Sequences

hello everyone, i got a problem with rotation matrices multiplication and i hope someone could help me tofigure that out…

So say that i want to perform a sequence of rotation in order xyz. Since opengl pre-multiplied, it’s multiplying in this way:

Rz * Rx * Ry

now i’ve implemented the matrix Rz * Ry * Rx on my own and it looks exactly like the xyz matrix in the Matrix Table at the bottom of this link:

comparing the two rotations i figured out that this matrix perform the following opengl sequence of rotation:

glRotated(az,0,0,1)
glRotated(ay,0,1,0)
glRotated(ax,1,0,0)

but i was sure the order for an xyz rotation is:

glRotated(ax,1,0,0)
glRotated(ay,0,1,0)
glRotated(az,0,0,1)

How is this possible? Where am I wrong?
thanks a lot

Euler lived as a very successful mathematician and inventor, but his skills in money-earning weren’t terribly great. A friend had covertly collected sums of earnings all from the profits off of Euler’s work. One day while feeling disappointed, Euler decided to travel to a relative out of state from boredom. His friend stopped him, politely asking that he make a puzzle toy for a daughter.

Since Euler enjoyed circles, he decided to form a puzzle out of the rim of one. He began to have fun to the point of accidentally discovering that certain multiples of flat lines could evenly join together. We profit today in 3D graphics since “round” objects are really made up of a bunch of triangles. This holds true even with NURBS.

The idea of a “unit circle” also applies to creating your own matrix. If the math calculates wrongly, things will bend oddly out of shape during a turn of some sort. A unit circle shows force applied to X and Y as a unit of 1. Add a third dimension as Z, and you have yourself a sphere.

Notice that X, Y, and Z all have a unit of 1. Basically, a matrix that allow circles also permits camera movement. To induce movement, you might first test out graphing a circle on an X and Y graph. With that complete, the third dimension Z will become compatible for your 3D matrix.

[quote]Euler lived as a very successful mathematician and inventor, but his skills in money-earning weren’t terribly great. A friend had covertly collected sums of earnings all from the profits off of Euler’s work. One day while feeling disappointed, Euler decided to travel to a relative out of state from boredom. His friend stopped him, politely asking that he make a puzzle toy for a daughter.

Since Euler enjoyed circles, he decided to form a puzzle out of the rim of one. He began to have fun to the point of accidentally discovering that certain multiples of flat lines could evenly join together. We profit today in 3D graphics since “round” objects are really made up of a bunch of triangles. This holds true even with NURBS.

The idea of a “unit circle” also applies to creating your own matrix. If the math calculates wrongly, things will bend oddly out of shape during a turn of some sort. A unit circle shows force applied to X and Y as a unit of 1. Add a third dimension as Z, and you have yourself a sphere.

Notice that X, Y, and Z all have a unit of 1. Basically, a matrix that allow circles also permits camera movement. To induce movement, you might first test out graphing a circle on an X and Y graph. With that complete, the third dimension Z will become compatible for your 3D matrix.
[/quote]
Probably I may not have been clear about my question…

a sequence of rotation xyz is mathematically calculated as RzRyRx (where R is a matrix).

Rz * Ry * Rx = [[czcy, -szcx + czsysx, szsx + cz cxsy]
[sz
cy, cxcz + szsysx, -sxcz + szsycx]
[ -sy, cysx, cycx]]

where cx = cos(x) sx = sin(x) etc…

Now… opengl is supposed to pre multiply the matrices then:


rotation sequence: xyz
glRotated(ax,1,0,0)
glRotated(ay,0,1,0)
glRotated(az,0,0,1)  

and this should be the same of RzRyRy… but it seems like it’s not since

Rz * Ry * Rx correspond to :

glRotated(az,0,0,1) 
glRotated(ay,0,1,0)
glRotated(ax,1,0,0)

and i am just wondering what am i doing wrong. I mean isn’t openGl pre multiplying or what?

OpenGL supposedly takes an odd approach with how it works in regard to matrices. While I haven’t examined that portion of code recently to explain in detail, it holds objects in different virtual spaces with one I think as upside-down. Perhaps you have come across that. I don’t remember its purpose, but I believe that it partially mimics the human eye in how it receives visual communication.

I’ve spent time with JOGL and LWJGL recently to not worry about “re-inventing the wheel” so to speak in that area of study. You might consider an open-source API.

It seems like I made some steps forward and I figure out what is going on but not the reason for that… I hope someone could give me some clarifications…

Given a sequence of rotation: xyz -> rotate first around the x then around y and in the end around z, in OpenGL would be:

glRotated(ax,x)
glRotated(ay,y)
glRotated(az,z)

so what is going to happen in this case is:
1- A rotation around x of ax degrees moved the y and z axis in y’ z’ while x = x’
2- A rotation around y’ moved x’ and z’ in x’’ and z’’ while y’ = y’’
3- A rotation around z’’ moved x’’ and y’’ in x’’’ y’’’ while z’’ = z’’’

At this point I wonder: what’s the name of it? local axis? or something else, since local axis is often related to glPush/PopMatrix()?

the way to replicate, by hand, what happend using glRotated would be:

v' = Rx * Ry * Rz * v 
or 

v'  = Rx * v
v'' = Ry * v'
v'' = Rz * v''

this is, as far as i know in contrast with the standard linear algebra since in mathematics a rotation xyz is represented by the matrix multiplication

v' = Rz*Ry*Rx * v 

in this case what happens is this:

1- Rotation around z move x y in x’ y’ with z = z’
2- Rotation around y (not y’) move y’ z’ in y’’ z’’ with x’ = x’’
3- Rotation around x (not x’’) move x’’ y’’ in x’’ y’’’ with z’’ = z’’’

so how is this called? rotation around global axis? fixed asix or what?

In conclusion i figured out the behavior but still i don’t have idea what is going on…

Historical note: Euler angles have nothing to do with Euler…they should be called Rodrigues angles. Euler (in modern terms) represented rotations as a log mapping of Quaternions (theta times V). Many papers call “yaw, pitch, roll” ordering “Tait-Bryant angles”…which is also pretty goofy Tait was a die-hard quaternion-head at the center of the quaternion vs. vectors debate.

You might have run into gimbal locks, which is something that happens
when using Euler angles: http://en.wikipedia.org/wiki/Gimbal_lock

E.g. Given an object, you can reach the same orientation using
2 different rotation sequences with Euler angles:

Rotate on Y-axis by 90 degrees, then
rotate on X-axis by -90 degrees.

is the same as:

Rotate on X-axis by -90 degrees, then
rotate on Z-axis by -90 degrees.

Just hold a rectangular object with your hands and do the
above experiment yourself and you’ll realise that there’re
more than one way to arrive at the same orientation.

.rex

In OpenGL glRotated(ax, 1,0,0) will multiply the current model-view matrix M with a rotation matrix Rx on the right: new M’ = M Rx.
So the code above yields a new model-view matrix M’ = M Rx Ry Rz.
If you apply that M’ to some vertex coordinate v, you get v’ = M ( Rx ( Ry ( Rz(v) ) )
Informally, you pick up your object, first rotate it around Z, then around Y, the around X, finally you do whatever M specifies.
So in Euler notation that would be called the zyx order, not xyz.

Remark: mathematicians/physicists/many 3D modellers prefer Euler angles like xyz or zyx, since they usually look at coordinate systems where by convention the Z axis is pointing “upwards”. But in graphics hardware/OpenGL/D3D, the convention is that “Y is up”. In that case, Euler angles like yxz are more natural.
Informally, the Rz is a “roll” around the Z axis, followed by a “pitch” caused by Rx, followed by a “yaw” caused by the Ry

Euler apparently was one of the best note-takers among mathematicians, which helped the science come together in Europe and later the US of America. I think he just explained a set of rules that allowed other theories to “plug-in” much like how Java can have software API libraries that plug into it. In effect, his notes somehow aided with a transition from theory to law in public view.

I don’t know if he receives too much credit, but a few notable mathematicians used his work for founding their own both in design and legally for income.

Yeah, I don’t think that debate will ever die. On the Asia side of the planet, things tend to get read reversed and still make sense. A Rubik’s cube is very much like a 3D matrix.