# Help with matrix and point coordinates

I need some help with the following theory matter:

I have a point initially at 0,0,0

Suppose i do some translations and rotations. How do i get the new point coordinates ?
I suppose i have to get the resulting matrix with the glGetfloatv function, but which matrix values hold the xyz info ?

Thanks

Originally posted by Alessandro:
[b]I need some help with the following theory matter:

I have a point initially at 0,0,0

Suppose i do some translations and rotations. How do i get the new point coordinates ?
I suppose i have to get the resulting matrix with the glGetfloatv function, but which matrix values hold the xyz info ?

Thanks[/b]
Hello there,
All the info regarding the modelling (your points or object coordinates) and the viewing information is contained in the modelview matrix. Thanx
MMM

can you explain a little bit more ?

when you get the matrix from ogl I think it was
glGetMatrix

you get a array of 16 floats, which is a column major matrix, so your first column is 0-3, second 4-7 and so on

rotation/scale is stored in 0-11
translation is stored at 12-14

as modelview typically has no perspective stuff, 3,7,11 are 0 and 15 is 1

so matrix = x, matrix = y and matrix = z

best you learn about matrix math and homogenous space to understand what it is done to your vertices when they are transformed with the matrix, also how those matrices were created…

Thanks for your help. So if i translate and rotate an object as follows:

``````glTranslatef(0,0,-100);
glRotatef(-90,0,0,1);

``````

The relative matrix is:

``````| 0  1  0  0  |
|-1  0  0  0  |
| 0  0  1 -100|
| 0  0  0  1  |

``````

As you said, values from 0 to 11 contains the rotation, value 12,13,14 are the translation ones.
Where do i go from here if i want to get the new point coordinates ?

you multiply your vector with the matrix.

``````	vector = v1*mat[M00]+v1*mat[M01]+v1*mat[M02]+mat[M03];
vector = v1*mat[M10]+v1*mat[M11]+v1*mat[M12]+mat[M13];
vector = v1*mat[M20]+v1*mat[M21]+v1*mat[M22]+mat[M23];

the M<row><column> indices would be like M01 = 4, M21 = 6 and so on

v1 is your input vector and mat the matrix
``````