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!
Asked
Active
Viewed 1,115 times
0

J-S
- 425
- 3
- 17
-
Can we assume you are referring to the equivalent form of a Catmull-Rom spline? I.e. are the bezier control points derived from the previous and next curves? – StarShine Nov 28 '14 at 14:15
-
You mean "from the previous and next Splinepoints"? Then yes. Its mostly straigthforward implemented like here http://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf. Gluing connection points and matching first and second order derivatives. – J-S Nov 28 '14 at 14:36
-
Well for starters you can select only those curves that have a closest (or overlapping) bounding area. Then you iteratively subdivide these curves for a number of iterations and calculate the distance. If you have equal distances, then your solution includes multiple curves. – StarShine Nov 28 '14 at 15:36
1 Answers
0
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.

fang
- 3,473
- 1
- 13
- 19
-
Actually, the real distance is not required to find the closest curve. After 1 curve subdivision, you know which side of the curve is closest (or both in special cases). You can keep subdividing those for all segments until the distance delta becomes smaller than the difference in distance to the closest curve. – StarShine Nov 29 '14 at 00:29
-
Subdividing curves only makes the control polygon closer to the curve. But smallest distance to the control polygon does not necessarily mean smallest distance to the curve. – fang Nov 29 '14 at 00:39
-
The idea is to move the 'control polygon' of curve X closer to point p as long as the previous delta > distance-to-point-on-cloest-curve-Y. When that is no longer the case, X is not going to be closer than Y. So in fact you don't need X's exact closest point, because you know the next subdivision will never move closer to Y. – StarShine Nov 30 '14 at 12:24