 # local/global coordinate system problem

When I translate and rotate to a local coordinate system, how do i find the local coordinates of a point in global coordinates. In other words, I know the global coordinates for a vertex, then I move to a local coordinate system, how would I find the coordinates of the vertex with respect to the new local coordinate system?

Get the matrix that does the translations and multiply your vertex by it.

Chris

so, you mean use

``````glGetFloatv(GL_MODELVIEW_MATRIX,Minv);
``````

to store the system into Minv and then do something like this?:

``````void VMatMult(GLmatrix16f M, GLvector4f v)
{
GLfloat res;
res=M[ 0]*v+M[ 4]*v+M[ 8]*v+M*v;
res=M[ 1]*v+M[ 5]*v+M[ 9]*v+M*v;
res=M[ 2]*v+M[ 6]*v+M*v+M*v;
res=M[ 3]*v+M[ 7]*v+M*v+M*v;
v=res;
v=res;
v=res;
v=res;
}
``````

I think that’s right - I’m never quite sure what order GL’s matrices are in but I think you’ve got it.

Chris

Look at the other topic on matrix, I think we cover it pretty well now, it is over 70 replies now. I stopped following when it hit 50 Chris