Results 1 to 2 of 2

Thread: would you like to explain it for me ?

  1. #1
    Member Contributor
    Join Date
    May 2001
    Posts
    51

    would you like to explain it for me ?

    when i read "the red book" for Opengl, I cant understand this bellow:
    "Another way to view matrix multiplications is to forget about a grand, fixed coordinate system in which your model is transformed and instead imagine that a local coordinate system is tied to the object you're drawing. All operations occur relative to this changing coordinate system. With this approach, the matrix multiplications now appear in the natural order in the code."
    so i hope someone to explain it for me, the best way is presenting an example, i also want to know, wether the matrix multiplications have different order between using glPushMatrix(), glPopMatrix() and not using them.thanks.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: would you like to explain it for me ?

    Please don't crosspost on both forums.

    The use of Push/PopMatrix doesn't change the order of matrix operations. It's the only the interpretation of them that is changing.

    Personally I think the local coordinate interpretation is easier to understand than the global coordinate system, but you have to find out for yourself what you understand best.

    Every coordinate you give to OpenGL is relative to some coordinate system. glVertex3f(1.0, 0.0, 0.0) means one unit from the origin along the x-axis. When you write glTranslatef(0.0, 1.0, 0.0) this means "move the origin one unit along the y-axis". All further coordinates are relative to the new origin.

    Similar with rotations, glRotatef(45.0, 0.0, 1.0, 0.0) means "rotate the axes of the coordinate system 45 degrees around the y-axis).

    Code :
    So when you write:
    glTranslatef(1.0, 0.0, 0.0)
     
    you change your coordinate system:
    ^ y                        ^ y
    |                ->        |
    |                          |
    o-----> x            o     +-----> x
    |< 1 >|              |< 1 >|< 1 >|
    (with "o" being the old origin)
    = translate one unit along the x-axis
     
     
    but when you do:
    glScalef(2.0, 0.0, 0.0)
    glTranslatef(1.0, 0.0, 0.0)
     
    you get:
    ^ y                  ^ y
    |                ->  |
    |                    |
    o-----> x            o-----------> x
    |< 1 >|              |<    2    >|
    = scale the x-axis by two
     
                ^ y
                |
                |
    o           +-----------> x
    |<    2    >|<    2    >|
    = translate one unit (= 2 global units because of the scale) along the x-axis
     
    and when you do:
    glTranslatef(1.0, 0.0, 0.0)
    glScalef(2.0, 0.0, 0.0)
     
    you get:
    ^ y                        ^ y
    |                ->        |
    |                          |
    o-----> x            o     +-----> x
    |< 1 >|              |< 1 >|< 1 >|
    = translate one unit along the x-axis
     
          ^ y
          |
          |
    o     +-----------> x
    |< 1 >|<    2    >|
    = scale the x-axis by two (notice that the distance to the origin doesn't change)
    You have to see this as a way of "thinking in the right order". With this model you don't have to reverse the transformation order because you think of it in the same order than OpenGL does.

    I hope that was clear. Sorry for not giving an example with rotation, but thats not so easy with ascii-art .

    Overmind

Similar Threads

  1. explain please
    By always1 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-16-2002, 06:18 AM
  2. Can anyone explain glPolygonOffset?
    By billy in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-12-2002, 01:38 AM
  3. would you like to explain it for me ?
    By victorswan in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 02-11-2002, 11:51 PM
  4. please explain for me
    By victorswan in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-19-2001, 03:10 AM
  5. ase explain
    By odysseykre in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-30-2001, 01:45 PM

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