PDA

View Full Version : Transformation Matrix

Julie
04-29-2002, 11:29 PM
I need to control the transformation matrix with extern calculations.I have a problem to reconstitute the good transformations.
For the moment, I have a good representation while my view point is on the z axis.
But I certainly have a bad transformation, because if my point of vue takes some x or y coordinates, my object (a molecule) is badly placed.

I need to know exactly the whole steps of the transformation matrix.
Does anybody here could tell me how to reconstitute correctly the whole transformation ?

Morglum
05-01-2002, 11:11 PM
Hi !

Could you explain what you're trying to achieve, and why ordinary opengl transformations won't fit ? And, if it's only a problem with the point of view, have you tried gluLookAt ?

Now, if you really want to do your own matrix calculations, here's the matrix for a translation by vector (x, y, z) :
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
for a rotation by angle a around vector e = xe, ye, ze), it's a bit more tough. first find two vectors f, g orthogonal to e such that B=(e, f, g) is a basis of the space. In this basis, the matrix of your rotation is M=
1 0 0 0
0 (cos a) (-sin a) 0
0 (sin a) (cos a) 0
0 0 0 1
Now let P be the (3x3) base-change matrix :
xe xf xg
ye yf yg
ze zf zg
Compute the inverse P^-1 of P. Then the matrix of your rotation in the ordinary basis is simply:
P * M * P^-1

Hope this helps
Morglum

immy
05-02-2002, 05:53 AM
Hi!
Explain the problem fully, then hope u will get the result u want from here.
bye & good luck

nigels
05-02-2002, 03:48 PM
The GLT OpenGL C++ Toolkit includes
a 4x4 matrix class:
http://www.nigels.com/glt/doc/class_matrix.html

A class like this would probably useful