Results 1 to 2 of 2

Thread: I neeeeeed HELP with Rotation!!! as soon as posible!!

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    Sweden
    Posts
    2

    I neeeeeed HELP with Rotation!!! as soon as posible!!

    Let say I have a Spaceship in space.
    I also have a asteroid in the same space.
    I want a to be able to rotate a camera around the ship.

    I want to be able to rotate the ship, here is the big problem. When I rotate around the first axle (Let say X) the whole system rotates so when I later want to rotate around some other axle it have moved and the ship donít rotate as I want.

    Example:
    I rotate 90 degrees around X this moves Y to where Z was and Z to where Y was.
    If I now want to rotate around Z the ship will rotate around Y.
    And that is NOT what I want! ! !


    What I am trying to do is a Ship that:
    Turn its Nose UP or Down (its own X) when key pressed, however it is turned in any way.
    Rotates around its own Z when LEFT/RIGHT key is pressed

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2000
    Posts
    3

    Re: I neeeeeed HELP with Rotation!!! as soon as posible!!

    You can find these formulas pretty quickly anywhere on the web .. or in a decent book on 3D.

    It seems like you already have these (from my code):
    const double sx = sin(xAngle), cx = cos(xAngle);
    const double sy = sin(yAngle), cy = cos(yAngle);
    const double sz = sin(zAngle), cz = cos(zAngle);

    xtemp = points[i].X;
    ytemp = points[i].Y;
    ztemp = points[i].Z;

    points[i].X = xtemp;
    points[i].Y = (ytemp * cx) - (ztemp * sx);
    points[i].Z = (ytemp * sx) + (ztemp * cx);

    points[i].X = (xtemp * cy) + (ztemp * sx);
    points[i].Y = ytemp;
    points[i].Z = (ztemp * cy) - (xtemp * sy);

    points[i].X = (xtemp * cz) - (ytemp * sz);
    points[i].Y = (xtemp * sz) + (ytemp * cz);
    points[i].Z = ztemp;

    If you want to rotate around a local point (instead of axis) the easiest way is probably to translate the point(s) in respect to 0,0,0 and then back. Example if you want to rotate about 0,5,0 shift all the y-values by -5, rotate, and then shift all the y-values by +5 again. I know there are eqn's to rotate around a point in space instead of 0,0,0 but don't have my references here.

Similar Threads

  1. Rotation of an object by rotation matrix
    By MrFoil in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-02-2015, 04:41 PM
  2. Matrix Rotation loses 1 axes of rotation
    By Benzino in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-15-2011, 06:53 AM
  3. Replies: 1
    Last Post: 04-16-2010, 02:59 PM
  4. changing axis of rotation and center of rotation in openGL performer
    By ravishashi in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-08-2003, 04:42 AM
  5. Replies: 8
    Last Post: 06-26-2003, 04:42 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