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.


so, you mean use


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

void VMatMult(GLmatrix16f M, GLvector4f v)
    GLfloat res[4];
    res[0]=M[ 0]*v[0]+M[ 4]*v[1]+M[ 8]*v[2]+M[12]*v[3];
    res[1]=M[ 1]*v[0]+M[ 5]*v[1]+M[ 9]*v[2]+M[13]*v[3];
    res[2]=M[ 2]*v[0]+M[ 6]*v[1]+M[10]*v[2]+M[14]*v[3];
    res[3]=M[ 3]*v[0]+M[ 7]*v[1]+M[11]*v[2]+M[15]*v[3];

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


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