View Full Version : quaternion rotation parallel to horizont

SebastianB

07-10-2002, 11:19 AM

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

Junkstyle

07-10-2002, 12:28 PM

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.

coredump

07-10-2002, 12:47 PM

go here (http://www.makegames.com/3drotation) 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

SebastianB

07-10-2002, 10:05 PM

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

Gavin

07-11-2002, 01:24 AM

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?

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.