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 7 of 7

Thread: Simple Rotation Problem

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    3

    Simple Rotation Problem

    I would like to rotate a polygon (drawn by glutSolidCube) in a 3D enviroment. Suppose the white dot is the front view of X axis, my question is, I want to rotate it in this way:



    instead of in this way:



    just like the hour hand spinning around the clock center.

    Maybe it is a simple question but I cannot figure it out. Hope you guys can help me. Thanks a lot

  2. #2
    Junior Member Newbie
    Join Date
    Dec 2009
    Location
    Princeton, NJ
    Posts
    19

    Re: Simple Rotation Problem

    You need to translate before you rotate, probably by half the width of the polygon.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    3

    Re: Simple Rotation Problem

    Quote Originally Posted by Pziko
    You need to translate before you rotate, probably by half the width of the polygon.
    Thanks Pziko Would you please specify more? Since i am a newbie I don't understand this concept.

  4. #4
    Intern Contributor
    Join Date
    Feb 2010
    Posts
    59

    Re: Simple Rotation Problem

    i doubt
    this problem is about scalef.

  5. #5
    Advanced Member Frequent Contributor Ehsan Kamrani's Avatar
    Join Date
    May 2005
    Posts
    537

    Re: Simple Rotation Problem

    Quote Originally Posted by MSynth2000
    Quote Originally Posted by Pziko
    You need to translate before you rotate, probably by half the width of the polygon.
    Thanks Pziko Would you please specify more? Since i am a newbie I don't understand this concept.
    Actually you need to first rotate and then traslate your objects if you want to rotate around the world coordinate system.
    You need to think about local coordinate system and move from top to bottom. For example:
    R1
    T1
    rotates the coordinate system first and then translates it.However the following order:
    T1
    R1
    translates the local coordinate and then rotates it around itself, so you don't get that desired effect.

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2010
    Posts
    3

    Re: Simple Rotation Problem

    Thanks for your kind help I will keep trying with the method you guys provided.

    I have another problem. That is, when I rotate my polygon (drawn by glutSolidCube), the shape of the polygon has changed to parallelogram shape. How do I maintain the shape during rotation?
    Please be reminded that it is a 3D world.

  7. #7
    Advanced Member Frequent Contributor Ehsan Kamrani's Avatar
    Join Date
    May 2005
    Posts
    537

    Re: Simple Rotation Problem

    you need to specify the Projection Transform using gluPerspective() and pass correct aspect ratio to it.For example you can use:
    gluPerspective( 45.f, double( m_width ) / double( m_height ), 1., 10000. );
    m_width and m_height are the width and height of the window respectively.

Posting Permissions

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