# glRotate help

I have a question about glRotate: if I have a fixed point with known coordinates and I call a glRotate, how can I find the coordinates of the fixed point in terms of the new rotated axes?

Don’t know of an OpenGL call. However, you can perform the matrix multiplication yourself.

See any graphics book (e.g. Real-time Rendering, Computer Graphics: Principles and Practice, …), or the comp.graphics.algorithms newsgroup, or the ‘Math & Algorithms’ forum.

There are ways to find it out, but if you explain what you are trying to do maybe an easier way to handle it.

Originally posted by malancha:
[b]I have a question about glRotate: if I have a fixed point with known coordinates and I call a glRotate, how can I find the coordinates of the fixed point in terms of the new rotated axes?

you can use glGet [google it] and pass in the appropriate parameters. an example would be:

``````// AFTER you do your rotation...

float matrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);

// manipulate matrix to get what the values you need/want
``````

i hope that helps

-=[ regards ]=-

i would do the following:

glPushMatrix();
glRotate(…);
float ffMatrix[16];
glGetFloatv(GL_MODELVIEW_MATRIX, ffMatrix);
glPopMatrix();

Then you can find out the coordinates of the rotation from ffMatrix[2], ffMatrix[6], ffMatrix[10] for the x, y, and z coordinates respectively.

To find out where you rotated point is, scale your point’s coordinates for the x, y and z coordinates from above. ie.

point.x *= ffMatrix[2]
point.y *= ffMatrix[6]
point.z *= ffMatrix[10]

Hope that helps

Thanks for answering, people. Maybe I didn’t express myself clearly enough – what most of you have said will apply if I want to find the new viewport coordinates of a point that’s been rotated using glRotate. What I’m trying to do is to find the viewport coordinates in terms of the new axes, assuming that the point has remained unmoved.
Turns out that the solution’s fairly simple: all I have to do is project the x,y,z vectors of my point onto the new axes.