View Full Version : Moving the CAMERA along a HELIX...

OGL_PGR

06-25-2005, 06:09 AM

Please help me sort out the following issues:

Problem area: CAMERA & Helical Bezier Curve.

So far, Iam able to move the camera along a BEZIER Curve [ control points being read from a file ], but I am have problems with a HELICAL Bezier Curve.

The HELIX is along the X-Axis [RHS], going from -x to +x. As the CAMERA moves along the HELIX, all of a sudden, it rolls 180 degrees and this keeps happening at some points along the helix, until we run out of the curve.

Any solution for this [ i.e 180 degree roll of the camera ] ?

The second issue is that the rendering is too slow [ I guess < 1FPS ], when the HELICAL BEZIER path is displayed, but in a normal Bezier Curve [ about 20 control points ], the FPS count is more than 40, when the bezier path is displayed.

Thanks.

Originally posted by OGL_PGR:

The HELIX is along the X-Axis [RHS], going from -x to +x. As the CAMERA moves along the HELIX, all of a sudden, it rolls 180 degrees and this keeps happening at some points along the helix, until we run out of the curve.

Any solution for this [ i.e 180 degree roll of the camera ] ?

The effect you are seeing is called "Gimbal lock" you may want to look it up. The most common solution is to use quaternations for the rotation.

Originally posted by OGL_PGR:

The second issue is that the rendering is too slow [ I guess < 1FPS ], when the HELICAL BEZIER path is displayed, but in a normal Bezier Curve [ about 20 control points ], the FPS count is more than 40, when the bezier path is displayed.

Thanks.Could it be that not OpenGL is what is slowing you down but the computation of your camera path?

Well, maybe you're not technically getting "gimbal lock" but kind of the reverse effect: it may be that you're using asin/acos/atan, and those cannot distinguish between all quadrants. (atan2 can, because you supply both the Y and X coordinate)

Post the code you use to calculate the angles, and explain how you want to get from the "source variable" to the coordinates and angles - e.g. do you have a time variable that travels between successive points on the curve, or are you using one coordinate and are you trying to find the other coordinates and angles for it.

aside form differentiating your cuve analytically to get a tnb, you could use curve points to create the camera's vectors.

let pi be a point on the curve.

zaxis = pi-1 - pi

or

zxis = -(pi+1-pi)

xaxis = pi

xaxis.x = 0

yaxis = zaxis cross axis

this will work if pi and pi-1 are sufficiently close to one another, but not so close as to introduce floating point problems.

if you are deriving your control points from

x = r cos t

y = r sin t

z = a t

then analytic differentiation is straightforward.

curve tangent:

y' = -r sin t

z' = r cos t

x' = a

curve normal:

y'' = -r cost t

z'' = -r sin t

x'' = 0

bitangent = tangent cross normal

xaxis = -normal

yaxis = bitangent

zaxis = -tangent

something like that. the noraml always points at the xaxis, so you should experience no flipflops.

dont forget to normalize your vectors...

:eek:

ooops... binormal, not bitangent (thinking surfaces).

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.