Rotation problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Rotation problem

Post by Peter Müller »

Hi!
I've got a problem concerning the rotation of an vector (core::vector3d).

Image

On the delineation you can see an 3D unit circle, described the the normalized direction vector.

If I rotate the vector

Code: Select all

vector3df vDirection(0,0,1);
horizontal using the rotateXZBy method

Code: Select all

this->vDirection->rotateXZBy(10.0f, vector3df(0,0,0));
everythink is perfect and the vector is rotating like the red circle.

But if I want to rotate vertical, from point 1 to point 2 using the rotateXYBy method

Code: Select all

this->vDirection->rotateXYBy(10.0f, vector3df(0,0,0));
it doesn't rotate like the purple line is showing. Its rotating like the yellow circle :(

I also tried to use the rotateYZBy method and both, the rotateXYBy and rotateYZBy methods. Nothing helped.

While the horizontal rotation works perfect, the vertical went nuts.

Can somebody help me?
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
T101
Posts: 44
Joined: Thu Jul 29, 2004 4:41 pm

Post by T101 »

I think you're suffering from gimbal lock.

What you probably want to do is go from a yaw/pitch(/roll) rotation to a vector. (With roll being local to the camera)

Assuming you start with your vector pointing along the X-axis:

1. rotate first by roll (with just a vector roll is not applicable, like with a camera in an editor, but with offsets it is) - with Irrlicht this would be in the Y/Z plane I believe.
2. rotate by pitch - with Irrlicht this is the X/Y plane
3. rotate by yaw - in the X/Z plane
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

Thanks, i'll try it
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Post Reply