Separate rotations

This is a discussion on Separate rotations within the Game Programming forums, part of the General Programming Boards category; I'm writing a space game and I'm using a huge sphere centered around the player as the backdrop. A skybox ...

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586

    Separate rotations

    I'm writing a space game and I'm using a huge sphere centered around the player as the backdrop. A skybox didn't quite look right so I switched to a sphere. Here is my problem.

    When you fly straight up or straight down and attempt to move left or right - the craft spins. This is fine on planet earth since it is how aircraft really act. However in space this is not good. I want the craft to move left and right at any angle of rotation. In other words I don't want the x rotation mapped over the y rotation at any point in time. All rotations need to be separate. However with my current design, and no I'm not yet using quaternions, it doesn't work.

    Do I need to use the matrix for rotation about an arbitrary axis for all rotations and dump the x,y,z rotational matrices?

    I'm sorta stumped.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    So you are experiencing gimbal lock. You do need to dump the x, y, z euler angles. Axis Angle will solve your problem. I would really look into using quaternions so you can smoothly interpolate the rotation orientations if you ever need to. If you do not, then you can stick with axis angles. Enjoy.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    you could just minus the angle by what you plused it by. Do you get what I am saying or does your design not allow that?

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    you could just minus the angle by what you plused it by. Do you get what I am saying or does your design not allow that?
    No amount of altering any angle will solve the issue whilst using x,y,z rotational matrices. Problem is gimbal lock. There is a point at which one axis of rotation is mapped onto another axis of rotation. This is encountered in space craft quite a bit and is known as gimbal lock.

    In fact with the Apollo space program they trained rigorously on piloting the crafts because they could reach the dead band...or gimbal lock. At this point the craft had no directional control. Any rocket inputs would simply make the craft spin...not turn. But they also suffered from another type of gimbal lock in which a rotation could not be stopped because the rocket could not move to an angle sufficient enough to counteract the rotation.

    I believe the shuttle overcomes these problems by having multiple thrusters at multiple angles which cause multiple x,y, and z rotations. I don't think the shuttle can gimbal lock as the old space capsules could.


    EDIT:

    Easily solved by adding D3DXMatrixRotationAxis.

    So now my camera has 3 modes - aircraft, ground, and space.

    Thanks all.
    Last edited by VirtualAce; 09-23-2004 at 02:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. separate integer into individual units
    By manzoor in forum C++ Programming
    Replies: 9
    Last Post: 05-12-2008, 10:03 AM
  2. A reference to separate pairs of values
    By SevenThunders in forum C++ Programming
    Replies: 22
    Last Post: 04-03-2008, 05:06 PM
  3. Sin Tables (and rotations)
    By Epo in forum Game Programming
    Replies: 15
    Last Post: 05-29-2005, 05:41 PM
  4. Using strtok on separate functions
    By Thumper333 in forum C Programming
    Replies: 2
    Last Post: 10-24-2004, 02:19 PM
  5. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21