PDA

View Full Version : Help with Rotation Matrices

Halcyon
12-29-2002, 09:50 PM
Ok i'm a little confused with exactly how rotation matrices work. Say you have a model located at coordinates (0,0,0) or the origin of the world space...when you apply a rotation, the resulting coordinates will still be (0,0,0). If it were not centered at the origin, you'd get the location of the object but now the direction it is facing. Here is what i mean:

This is a rotation of an object located the origin around the z axis ( oh and ? is actually a theta):

[cos ? -sin ? 0 0] [ 0 ] [ 0 ]
[sin ? cos ? 0 0] * [ 0 ] = [ 0 ]
[0 0 1 0] [ 0 ] [ 0 ]
[0 0 0 1] [ 1 ] [ 1 ]

As you can see there is no indication of an actualy rotation. I'm read the book Real-Time Rendering and i'm gleaning this from there (the rotation matrix only). But from all the other transforms in the book it seems like the correct operation to get the resulting transformb X would be to use this formula:

X = Rz(?) * p

Where Rz(?) is the 4x4 rotation matrix in homogeneous coordinates and p is the point in matrix form with homogeneous coordinates.

Thanks for all the help in advance and i hope everyone has a happy new years!!

- Halcyon

P.S. Sorry for the crude matrix diagrams...i didn't know or a better way of doing them!

Edit: Sorry matrices were not aligned right

[This message has been edited by Halcyon (edited 12-29-2002).]

rixed
12-30-2002, 01:01 AM
I didn't understand what exactly gives you some trouble.

If you have a vertex at coordinate (x,y,z) you understand that by multiplying (x,y,z,1) by a 4x4 matrix will change this position, didn't you ?

And that by multiplying all the vertex of a geometric shape by an orthogonal(1) 4x4 matrix you will change the position and the orientation of the model without changing its shape, didn't you ?

((1) orthogonal for the rotation part of the matrix, that is : the rotation part of the matrix can be represented as an orthogonal coordinate system)

So whats your problem ?

(Note : I've written a tutorial about the use of matrix in opengl but its only in french. If you read it, you can find it at http://rixed.free.fr, texts section).

Halcyon
12-30-2002, 09:29 AM
Ok sorry...i was confusing myself. In the book Real-Time Rendering, it showed a picture of point rotations and how they worked. I got confused and thought they were saying to rotate a model about its center, you multiply a point near the middle of the model with the rotation matrix and you get the resulting transform. But it's actually the vertices that get multipled with the rotation matrix. And the vertices are translated until the point in the middle is located at the origin.

To make a long story short...i got confused..and i really appreciate your help!

Have an awesome new years

- Halcyon