Results 1 to 3 of 3

Thread: Rotations about an arbitrary axis

  1. #1
    Member Newbie
    Join Date
    Feb 2000
    Location
    Kingston, Ontario Canada
    Posts
    47

    Rotations about an arbitrary axis

    I have a vector, v = (v1,v2,v3), that I want to rotate about another vector r = (r1,r2,r3). I want to know the result, p = (p1,p2,p3), of this transfomration.

    Is there an easy way of doing this?

    glRotate3d does this automatically but I don't know how to get the result of its calculation.

    Can I get OpenGL to do the calculation for me and return the result?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    milano, italy
    Posts
    282

    Re: Rotations about an arbitrary axis

    sure! the steps are:
    -setup a identity matrix
    -translate by your source point
    -rotate about the axis
    -retrieve the translation vector of the matrix

    in code:

    glMatrixMode(GL_MODELVIEW_MATRIX);

    glLoadIdentity();
    glTranslatef(v1,v2,v3);
    glRotatef(degrees,r1,r2,r3);

    float matrix[4][4];
    glGetFloatv(GL_MODELVIEW_MATRIX,(float *)matrix);

    your transformed point is hold into the last row of matrix, matrix[3], so:

    p1=matrix[3][0]
    p2=matrix[3][1]
    p3=matrix[3][2]

    Dolo/\/\ightY

    [This message has been edited by dmy (edited 03-27-2000).]
    Dolo/\/\ightY

  3. #3
    Member Newbie
    Join Date
    Feb 2000
    Location
    Kingston, Ontario Canada
    Posts
    47

    Re: Rotations about an arbitrary axis

    Thanks for your help DMY -I really appreciate it.

Similar Threads

  1. N-Arbitrary Rotations -> Euler angle shortcut?
    By paradoxresolved in forum OpenGL: General
    Replies: 3
    Last Post: 11-12-2013, 05:55 PM
  2. Rotations about arbitrary axis
    By errfet in forum OpenGL: General
    Replies: 2
    Last Post: 10-17-2011, 04:22 AM
  3. Rotation about an arbitrary axis
    By WillieD in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-06-2005, 05:00 PM
  4. Replies: 1
    Last Post: 06-09-2005, 12:39 PM
  5. Rotation around arbitrary axis
    By Lord Chaos in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 04-27-2000, 11:24 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