Results 1 to 5 of 5

Thread: problems with rotations

  1. #1
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    problems with rotations

    hi,

    I am having a problem with a simple rotation problem.I have attached a rectangle to a coordinate axes such that one of its vertices align with the origin.I want to translate rectangle center to the origin and rotate the rectangle with respect to the current center.
    In init() I translated rectangle's center to origin.Now I need to rotate it in run(). what Ive done is
    init()
    {
    translate(T);
    scale(s);
    rectangle();
    }
    in run()
    {
    gltranslate(-T)
    rotate(x,1,0,0);
    gltranslate(t);

    }
    The problem is the rectangle is always rotating wrt to the vertex but not the center of the rectangle.what is the problem with my code??Can someone help me please.

    Thank you.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    134

    Re: problems with rotations

    What happens if you leave out the translates in run() out? That will change the center of rotation.

  3. #3
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    Re: problems with rotations




    glrotate(x,1,0,0);
    gltranslate(t)
    glscale(s);
    rectangle();

    Is this thing right??This thing dont work for me.I want to rotate the rectangle about its center.I also want to do the scale about the center.Thanks in advance.

  4. #4
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    Re: problems with rotations

    Quote Originally Posted by todayman
    What happens if you leave out the translates in run() out? That will change the center of rotation.
    I removed the translates out it doesnt work!! Its rotating with the vertex as center.

    what should my matrix transforms order be??Otherwise Im just setting the matrix directly in run() what Ive to do,

    S*R*T is not working??



  5. #5
    Member Contributor
    Join Date
    Sep 2008
    Posts
    65

    Re: problems with rotations

    Thank you very much.I did it.

Similar Threads

  1. 3D Rotations
    By danBuonocore in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-15-2013, 12:03 AM
  2. rotations
    By mikethebike in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-04-2013, 09:15 AM
  3. VP rotations
    By MojoMagic in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 02-25-2004, 07:12 PM
  4. Problems with translations/rotations...
    By Evil-Dog in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-29-2001, 11:49 AM
  5. Rotations
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-14-2000, 02:00 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