Yaw, Pitch & Roll

Please help me to extract Yaw,Pitch & Roll angles from a curve…

I have a cubic spline in 3d space and I have an object that moves along the curve( Basically, trying a simulate a roller-coaster kind of motion )

So, based on any 2 points on the curve ( say, deltaCurrent and deltaNext ), is it possible to get Yaw, Pitch and Roll angles ?

After getting the 3 angles, I’m hoping that this method would work:

//------ Start of DrawGL() ---------

// I’m assuming that object-axis = x-axis

0)glPushMatrix();

1)glTranslatef(deltaCurrent);
2)glRotatef(-Yaw, 0.0f, 1.0f, 0.0f);
3)glRotatef(-Pitch, 0.0f, 0.0f, 1.0f);
4)glRotatef(-Roll, 1.0f, 0.0f, 0.0f);
5)DrawOject();

6)glPopMatrix();


// move the object to next point on the
// cubic spline
7)UpdateObjectPosition();

//------ End of DrawGL() ---------

Please help me out !

Thanks.

It is possible, but somehow complicated.
In fact, to build a transformation in matrix form you can get around these angles, calculating a transform directly out of your “coaster track”.
The idea is to extract two vectors: An “forward” vector, that points forward from the object, eg. tangent to the spline, and an simple “up” vector, that directs the object’s top. (mostly (0,1,0) ) The idea is to build a transform like that:
-Use the normalized “forward” as -z -Vector.
-Orthonormalize the “up”-vector
-find the third direction by cross-product.
these three vectors now builds up an orthonormal matrix, hence the needed transform to align the object with the track, standing upright to “up”.

You can displace the original “up”-vector to do things as roll movement in fast coaster curves.

AFAIK this trnsform can be automatically computed as i explained above by:
gluLookAt(obj.x, obj.y, obj.z, at.x, at.y, at.z, up.x,up.y,up.z);
this command is made for camera orientation, but should work as well for object transform.
You could set obj=(0,0,0), at=tangent to your spline and up=(0,1,0) for a first test.
calling the above command should then align the object to the coaster track.
if you want to include even the placement of the object, you could try something like:

obj=deltaCurrent
at =deltaNext (a track position slightly before me (~length of object ahead should be good))
up=(0,1,0)

although thats not what you questioned for, maybe its helps

greets
Paul

Hi Paul !

Thanks for the explanation.

Right now, the camera moves along the spline with out any problems.

Until now, the UP-VECTOR = constant (0,1,0);
But, how do I add dynamic roll to the camera ??

If I project the Look-Vector on the Y-Z plane and then calculate the angle between this vector and Y axis, will that give me ROLL ?

Also, how do I create a uniformly distributed set of points in 3d space ? ( given box’s top left and bottom right corners )

Looking forward to your input(s)…

Thanks.