Bspline, distance to segment, simpler than distance to point on curve?

1.2k views Asked by At

Given:
A spline from concatenated bezier curves.
A point

Desired:
Finding the one bezier curve of the spline, that is closest to that point.

Solution:
Iteratively finding the closest point on each bezier curve and selecting the curve with the overall closest point.

Question:
Is there a simpler way to do this, if the exact point on the curve is not needed? E.g. an operator to compare two bezier curves distances to the given point, from their controlpoints?
I don't need to know the distance to curve A,B,C ... I "only" need to order the curves by their relative distance. (--> find the closest curve, not the closest point.)

Thanks!

1

There are 1 answers

3
fang On

You can find the minimum distance and maximum distance between the point and the curve's bounding box. These two distances should be the lower bound and upper bound for the real distance between the point and the curve. So, you have

MinDist(P, Bbox(C1)) <= Dist(P,C1) <= MaxDist(P, Bbox(C1))
MinDist(P, Bbox(C2)) <= Dist(P,C2) <= MaxDist(P, Bbox(C2))

If you can also find that MaxDist(P, Bbox(C1)) < MinDist(P, Bbox(C2)) or MaxDist(P, Bbox(C2)) < MinDist(P, Bbox(C1)), then you can conclude which curve C1 or C2 is closer to point P. However, if you did not have these conditions, then finding out the lower/upper bounds will not help you and you will need to compute the real distance between the point and the curve.