从锚点到贝塞尔曲线的最大距离是多少?
给定三次贝塞尔曲线 P0,P1,P2,P3,具有以下属性:
• P1 和 P2 位于 P0 和 P3 所形成的直线的同一侧。
• P2 可以投影到P0 和P3 形成的线段上,但P1 不能。
曲线上距 P3 最远的点的 T 值是多少?
这是一张带有 示例曲线的图像。曲线向左凸出,因此曲线上有一个点距离 P3 比 P0 更远。
我找到了这个参考,用于查找从任意点到曲线的最小距离。反复试验是解决最大距离的唯一方法吗?该点是曲线上的锚点有什么区别吗?
谢谢
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 maximum distance as well? Does it make any difference that the point is an anchor on the curve?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这篇wiki 文章中给出了三次贝塞尔曲线的公式。使用简单的微积分,您可以找到参数 t 处曲线的切线 B'(t) 的公式。
曲线距 P3 最远点的特征是切线 B'(t) 垂直于向量 B< /strong>(t)-P3。
因此,您需要找到 t 的值,其点积 B'(t)⋅(B(t)-P3)=0。
顺便说一下,您正在求解 t 中的五次方程,因此准备好进行一些求根操作。我通常期望区间 [0,1] 中有一个根,但我认为 Pi 的某些配置可能有多个根(在这种情况下,你选择距离最大的一个)。
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.