Results 1 to 6 of 6

Thread: local/global coordinate system problem

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    12

    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. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    State College, PA
    Posts
    186

    Re: local/global coordinate system problem

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

    Chris

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    12

    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. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    State College, PA
    Posts
    186

    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. #5
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Posts
    370

    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. #6
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    State College, PA
    Posts
    186

    Re: local/global coordinate system problem

    I stopped following when it hit 50

    Chris

Similar Threads

  1. Render frustum and local coordinate system
    By Mikael Ara in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-29-2012, 01:21 PM
  2. local camera coordinate system - help
    By pyramation in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-06-2010, 12:39 AM
  3. calling glVertex*() on local coordinate system
    By jkj2000 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-27-2006, 02:12 AM
  4. Local and global coordinate system
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-12-2002, 07:10 PM
  5. Global Coordinate System Transformations
    By mbonika in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 02-27-2000, 08:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean