Results 1 to 5 of 5

Thread: quaternion rotation parallel to horizont

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Stuttgart, Germany
    Posts
    27

    quaternion rotation parallel to horizont

    ok, here again my algorithm:

    ---------------------
    // compute quatRotation
    BasicQuaternion *quatRotation = new BasicQuaternion(angleX, angleY, 0);


    // multiply quatRotation with quatOrientation
    quatOrientation.PostMult(*quatRotation);

    // compute direction from new quatOrientation
    quatOrientation.GetDirectionVector(&direction);
    ---------------------

    what i wanted to do was direct my camera like in other first-person-games. when i look down (mouse downwards), i want mouse-sidewards-movements to rotate my camera parallel to the horizont.
    but it rotates relative to the point i look at

    i think i know why it is so, but i just cant manage to make it rotate parallel to the horizont ... can please anybody give me a hint?
    i tried to generate the quatRotation by euler-angles, but the same effect ......



    seb

  2. #2
    Member Newbie
    Join Date
    Jul 2002
    Posts
    42

    Re: quaternion rotation parallel to horizont

    I see no reason why you need to use quaternions for a FPS viewpoint. You only have 2 axis rotations and even those are constrained. The look up / look down usually only allows you to look 90degrees up or 90degrees down (maybe 89.9 degrees). You aren't going to have gimbal lock, and you also don't have to interpolate between 2 quaternions for a smooth animations or transitions, since fps need high twitch reactions to movement. Also you don't need to rotate around an arbitrary axis, since you will be rotating around y-axis and z-axis only (assuming your foward vector is the x-axis).

    Anyways I could be wrong because I'm a OGL newbie, but I myself am working with quaternions *groan* and if I didn't have to I wouldn't. I don't really understand the math of quaternions and I'm not into the appeal of fancy names and formulas.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    184

    Re: quaternion rotation parallel to horizont

    go here and look for the section titled "Other Ways to Make a Rotation Matrix". that section introduces a set of formulas for making a rotation matrix from an arbitrary axis and an angle in radians. you can keep track of the camera's up, right and look vectors in your code. each time through your loop, calculate the difference in x and y mouse movement. generate angles from these and use the formula to make rotation matrices to transform your look, up and right vectors. for example, if the user moves the mouse up (i.e. looking up) you generate a rotation matrix about the camera's right vector, then multiply your look and up vector by this matrix. if he user moves the mouse left or right, make a matrix from the vector (0, 1, 0) and transform look, up and right. this will keep the rotation the way you want it. you'll need to keep these vectors orthogonal.

    b

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Stuttgart, Germany
    Posts
    27

    Re: quaternion rotation parallel to horizont

    ok, i will think about that. thanks a lot.

    the problem, why i have the FEELING i need quaternions, is that i am doing an outdoor game, with vehicles, and so they have to be rotated according to the terrain theyre on .... 3 degrees of freedom.

    maybe im just to unexperienced with 3d-maths to know if i can do that without these damn quats.

    can i ??



    seb

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: quaternion rotation parallel to horizont

    Its not really the fault of quats though is it! Perhaps I don;t get this but you want left right to be like spinning around and up down to tilt your head back and forward?

Similar Threads

  1. Quaternion for rotation on X and Y
    By johnnie90 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-27-2013, 07:30 PM
  2. Rotation Parallel to Vector
    By MichaelA in forum OpenGL: General
    Replies: 12
    Last Post: 12-25-2010, 07:34 PM
  3. Quaternion Rotation
    By maedhros777 in forum OpenGL: General
    Replies: 5
    Last Post: 06-20-2010, 08:06 PM
  4. Rotation with Quaternion
    By JonasJ in forum OpenGL: GLSL
    Replies: 1
    Last Post: 06-02-2006, 12:59 PM
  5. Need help showing parallel lines during rotation
    By johnquinn888 in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 10-21-2004, 08:40 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