OpenGL Library for Delphi,
maintained by Eric Grange,
based on Mike Lischke's GLScene.

 

User Tutorials - Pitch Roll and turn angles

Tutorial 4
This tutorial is based on the work done in previous tutorials 1, 2 and 3.

You may have noticed the PitchAngle, RollAngle and TurnAngle properties on GLLines1.

image

and wondered why there are not used instead of the rather confusing Direction and Up vectors. Some rather complex 3D math comes into play here but I’ll attempt to explain when you should and when you should not use these properties.

First thing to note is the fact that any of the three angles (Pitch, roll and turn) are defined relative to the objects own coordinate system and not against the coordinate system of the parent like is the case with the Position, direction and Up vector.

This is a confusing situation because if you change the PitchAngle from 0 to 30 degrees then the object will pitch 30 degrees from it’s current pitch angle. The objects coordinate system, direction vector and Up vector are all updated. Let’s try it.


pic

The result is that the GLLines1 object pitches 30 degrees like so:

pic

Did you notice in the above object inspector how the Direction Vector has changed? So if the Pitch is relative to the objects coordinate system. How come that the pitch still shows 30 while the GLLines1 object has a pitch of 0 relative to it’s own coordinate system.

Indeed, confusing. The way GLScene implements these angles is that behind the scenes the library is simply instruction to pitch the coordinate system around the X axis by the change of the PitchAngle. In our example the old PitchAngle was 0, the new one was 30 therefore the pitch change was 30.

So if you now enter PitchAngle = 20 you will find that the delta pitch is -10 and the coordinate system will come back in pitch by 10 degrees.


Now, let’s take control of this object and align the Direction vector back with the Y axis as it was before.


Have a good look at the Form and object inspector. The direction vector corresponds with what you see on the form but the PitchAngle still shows 20!

pic

Yeah, have a coffee at this point and a little cry. It just isn’t fair. What is happening is that within the objects coordinate system the object was told to pitch 20 degrees. After that we re-aligned the coordinate system with the Y axis and thus the GLLines1 object points up again. Guess what happens if you set PitchAngle to 0? Right.

Conclusion: Using Pitch, Roll or turn is useful as long as you don’t mix it’s use with the Direction and Up vector. Another important limitation is that you should not manipulate the object around more than one axis.

Let’s prove this with another example.


You should see this again:

pic

Now let’s pitch this object up by a 60 degrees, around by 135 degrees and back down to a pitch of 0. You would expect this right?

pic

But that is NOT what you are going to see. Try it now and observe the form after each step.


pic

As you could see. After each step the objects coordinate system changes and therefore subsequent steps are performed in a different coordinate system that has a different orientation. A good way to overcome the complex gimbal error issues is by using TDummyCube objects to construct a logical pivot system. This Tip describes how to build a tripod for your TGLCamera.

The best thing to do is go back and re-read the topic about vectors if not fully understood. Or refrain from manipulating more than one angle on an object.
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 1.3901 seconds