Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Rotating a poly into XY-plane

  1. #1
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Rotating a poly into XY-plane

    Hi everyone.

    I need to rotate a polygon so that it lays only in one plane (ie XY). I need to do this, because only then i can calculate the texturecoordinates in my editor.
    I know about matrix-multiplication and i am not that bad at vector maths, but i donīt think my approach will ever work. So i would like to ask if someone could explain it to me.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    668

    Re: Rotating a poly into XY-plane

    Do you mean that you want to recover the rotation between a randomly rotated polygon and the one where its normal is 0,0,1?

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    Duluth, MN, US
    Posts
    22

    Re: Rotating a poly into XY-plane

    Hi Jan2000

    I think what I would do is the Gram-Schmidt orthogonalization process. Your polygon has some kind of vertices in a plane I would imagine. The plane should be spanned by two vectors. In the xy-plane, the spanning vectors would be {(1,0,0),(0,1,0)}. All the points of your polygon will be linear combinations of these two vectors. Say one point is (c1, k1,0) = c1*(1,0,0)+k1(0,1,0)

    If you wish to transform your polygon to a different plane, perform the gram-schmidt process to get two orthogonal vectors for your new plane. Say your new spanning vectors are v1, v2. Your polygon in the new plane is the same linear combination of the new vectors. So your first point (c1,k1,0) goes to c1*v1 + k1*v2 in the new plane.

    The entire process should be explained in detail in an (advanced?) linear algebra book.

    I hope that helps.
    Originally posted by Jan2000:
    Hi everyone.

    I need to rotate a polygon so that it lays only in one plane (ie XY). I need to do this, because only then i can calculate the texturecoordinates in my editor.
    I know about matrix-multiplication and i am not that bad at vector maths, but i donīt think my approach will ever work. So i would like to ask if someone could explain it to me.

    Jan.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    668

    Re: Rotating a poly into XY-plane

    Well you should be able to work out the axis of rotation and the angle pretty easily between the 2 planes. This is a quaternian (in effect) and you can make a transformation matrix from this and just use glMatrixMult.

Posting Permissions

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