Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » OpenGL and Gimbal Lock

Credits go to SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
OpenGL and Gimbal Lock
Myrdos
Member #1,772
December 2001

In the OpenGL Red Book, they have the following example for changing the viewing angle:

#SelectExpand
1glRotated(roll, 0.0, 0.0, 1.0); 2glRotated(pitch, 0.0, 1.0, 0.0); 3glRotated(heading, 1.0, 0.0, 0.0);

However, doesn't applying successive rotations like this introduce gimbal lock? Is there a way to combine the roll, pitch and yaw into a single operation? Or is that necessary?

__________________________________________________

SiegeLord
Member #7,827
October 2006
avatar

Create a rotation matrix from a quaternion, and load it in with glMultMatrix.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Myrdos
Member #1,772
December 2001

Awesome! That's just what I was looking for. :-*

__________________________________________________

Tobias Dammers
Member #2,604
August 2002
avatar

SiegeLord said:

Create a rotation matrix from a quaternion, and load it in with glMultMatrix.

Alternatively, store rotations as pairs of axis and angles, and use a single call to glRotatef(). Such an axis/angle pair can also be constructed from a quaternion with little effort.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Myrdos
Member #1,772
December 2001

Alternatively, store rotations as pairs of axis and angles, and use a single call to glRotatef(). Such an axis/angle pair can also be constructed from a quaternion with little effort.

I wonder: If I'm using quaternions for interpolation anyways, does it matter if I convert the quaternion to euler angles or to axis/angle pairs when rotating?

__________________________________________________

Go to: