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 4 of 4

Thread: distance from point to spline

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Bologna,Italy
    Posts
    16

    distance from point to spline

    Any one know a good code in order to compute the near point in a spline to a given point?
    Thanks in advance

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: distance from point to spline

    mmm... perhaps finding the closest point on the polyline hull will work or give a reasonably close result in some cases.

    Ask in a comp.algorithms group

    V-man
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Computer Graphics Group, RWTH Aachen, Germany
    Posts
    137

    Re: distance from point to spline

    Hi,

    Please see my reply in this thread: http://www.opengl.org/discussion_boa...ML/002519.html
    it gives the basic way to find an exact solution of the problem. It is usually faster than the approximation approach.

    Regards
    Martin

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Computer Graphics Group, RWTH Aachen, Germany
    Posts
    137

    Re: distance from point to spline

    Hi,

    Sorry, you actually asked for a solution in the general spline case. So for it you can use the fact that the spline is a polynomial between every two succesive control points/knots. Then you use the numerical method described in the thread which I mentioned above.
    If the used basis are the BSplines, then finding this polynomial is usually trivial - depending of the spline order. In case you use dont use compact functions basis, it is a bit harder...

    Regards
    Martin



    [This message has been edited by martin_marinov (edited 10-29-2002).]

Posting Permissions

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