Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Moving the CAMERA along a HELIX...

  1. #1
    Intern Newbie
    Join Date
    Jul 2004
    Location
    Bangalore
    Posts
    37

    Moving the CAMERA along a HELIX...

    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.

  2. #2
    Guest

    Re: Moving the CAMERA along a HELIX...

    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?

  3. #3
    Member Regular Contributor
    Join Date
    Jan 2004
    Posts
    322

    Re: Moving the CAMERA along a HELIX...

    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.

  4. #4
    Guest

    Re: Moving the CAMERA along a HELIX...

    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...

  5. #5
    Guest

    Re: Moving the CAMERA along a HELIX...



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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •