# Thread: local/global coordinate system problem

1. ## 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?

2. ## Re: local/global coordinate system problem

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

Chris

3. ## Re: local/global coordinate system problem

so, you mean use

Code :
`glGetFloatv(GL_MODELVIEW_MATRIX,Minv);`
to store the system into Minv and then do something like this?:

Code :
```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];
v[0]=res[0];
v[1]=res[1];
v[2]=res[2];
v[3]=res[3];
}```

4. ## Re: local/global coordinate system problem

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

5. ## Re: local/global coordinate system problem

Look at the other topic on matrix, I think we cover it pretty well now, it is over 70 replies now.

6. ## Re: local/global coordinate system problem

I stopped following when it hit 50

Chris

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•