What is the maximum distance from an anchor point to a bezier curve?
Given a cubic bezier curve P0,P1,P2,P3 with the following properties:
• Both P1 and P2 are on the same side of the line formed by P0 and P3.
• P2 can be projected onto the line segment formed by P0 and P3 but P1 cannot.What is the T value for the point on the curve farthest from P3?
Here is an image with an example curve. The curve bulges on the left, so there is a point on the curve farther from P3 than P0.
I found this reference for finding the minimum distance from an arbitrary point to a curve. Is trial and error the only way to solve for maximu开发者_开发问答m distance as well? Does it make any difference that the point is an anchor on the curve?
Thanks
The formula for a cubic Bezier curve is given in this wiki article. Using simple calculus, you can find the formula for the tangent B'(t) of the curve at parameter t.
The farthest point of the curve from P3 is characterized by the tangent B'(t) being perpendicular to the vector B(t)-P3.
So you need to find the value of t for which the dot product B'(t)⋅(B(t)-P3)=0.
Offhand, you're solving a quintic in t, so prepare to do some root finding. I'd typically expect one root in the interval [0,1], but I suppose some configurations of the Pi could have more than one root (in which case you select one that gives the largest distance).
Well, a bound is easy to compute.. just the maximum distance to the convex hull.
If you're looking for a precise answer, then you'll have to do a search.
精彩评论