逆向工程贝塞尔曲线

发布于 09-05 20:46 字数 406 浏览 8 评论 0原文

给定 贝塞尔曲线 上的几个样本点,是否可以计算出这些点可能位于的一组可能的曲线?

在我的特定应用程序中,曲线可能具有一组有限的端点,因此我想生成一组可能的曲线,枚举所有曲线并挑选出所有可能以有效端点结束的曲线。

有些人要求了解更多细节。 我有一组点,我知道它们位于 二次< /a> 贝塞尔曲线,我想计算曲线的公式并能够推断曲线上的新点。

Given a few sample points on a bézier curve, is it possible to work out the set of possible curves these points may lie on?

In my specific application there is a limited set of endpoints the curve may have, so I want to generate the set of possible curves, enumerate all of them and pick out all the ones which may end on a valid end point.

Some people have asked for more detail.
I have a set of points which I know are on a quadratic bezier curve, I want to calculate the formula of the curve and be able to extrapolate new points on the curve.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放肆2024-09-12 20:46:08

贝塞尔曲线将始终经过起始和结束控制点。

如果曲线的阶数等于样本点的数量,那么将只有一条曲线通过所有点(在正常情况下,所有点都不同,并且它们不位于 的贝塞尔曲线上)程度较低)。

如果曲线的次数小于样本点的数量,那么在一般情况下,您将无法使曲线经过所有点(正常情况下)。

如果曲线的阶数高于样本点的数量,那么在一般情况下,您将能够绘制无限数量的曲线。

wiki 文章中,您将仅找到对控制点的引用,但仍然我相信我正确地记住了上述属性,并且它们也适用于曲线上的点。

我认为你需要重新定义你的问题并准确定义你需要什么类型的曲线(以及什么程度)。另外,正如乔治指出的那样,您可能正在寻找路径 - 曲线的组合。

编辑
首先,用度数加上多个控制点点(二次需要三个)来定义校正曲线。控制点与曲线上的点不同 - 对于曲线和二次曲线上的三个点,您可能有无限多个解决方案(请参阅 this 对于二次曲线和四个点)

至于解决方案(但仍然假设您正在查看一条曲线):

对于单个二次曲线的方程,您有

B(t) = (1-t)^2*P0 + 2*(1-t)*t*P1 + t^2*P2

大写字母上面是向量,P0对应起始控制点(第一个点),P2对应结束控制点(最后一个点),所以还需要找到P1。变量 t 是范围从 0 到 1 的标量。

如果使用 2D 曲线,上述矢量方程为曲线上的每个点给出两个标量方程。

仍然存在 t 作为未知数,因此您应该再取 2 个点(总共 4 个),这将为您提供 4 个未知数(t 表示第一个点,t 表示第二个点,P1 的 x 和 y,中间控制点)和 4求解方程(每个样本点 2 个)。

用您最喜欢的数值方法解决这个问题,您将得到点所在的原始曲线。

如果您仍然认为可以获得更多曲线并且必须选择一些东西,那么您就不是使用贝塞尔曲线,而是使用 贝塞尔样条线(在某种意义上,多条曲线连接在一起)。同样的原理仍然适用,如果您想出一种方法来从上述方程中求解单个曲线(并且如果您有足够的点),那么您可以将问题划分为 n 段实际贝塞尔曲线,并按照上面概述的方式求解每个曲线。

如果事实证明您没有足够的积分,请再次查看链接的文章 - 您可能正在寻找最平滑的曲线,并且文章中有一些关于如何到达那里的建议,因为寻找精确的解决方案(最短曲线/最平滑曲线)似乎相当复杂。

Bezier curves will always go through starting and ending control points.

If the degree of the curve is equal to the number of sample points then there will be only one curve that will pass through all your points (in a normal case, where all points are different and they don't lie on a bezier curve of a lesser degree).

If the degree of a curve is less then the number of the sample points then, in general case, you will not be able to make the curve go through all the points (in a normal case).

If the degree of a curve is higher then the number of the sample points then, in general case, you will be able to draw infinite number of curves.

In the wiki article you will find references to control points only, but still I believe that I remember the above properties correctly and that they hold for the points on the curves as well.

I think you need to redefine your question and exactly define what type of curves (and of which degree) do you need. Also as Georg pointed out you might be looking for paths - a combination of curves.

EDIT:
First a correction - curve is defined with degree plus one number of control points points (quadratic need three). Control points are not the same as points on the curve - and for three points on the curve and quadratic curve you could have infinite number of solutions (see this for quadratic curve and four points)

As for the solution (but still under assumption that you are looking at a single curve):

For an equation for single quadratic curve you have

B(t) = (1-t)^2*P0 + 2*(1-t)*t*P1 + t^2*P2

Capital letters above are vectors, and P0 corresponds to starting control point (first point), P2 corresponds to ending control point (last point), so you still need to find P1. The variable t is scalar that ranges from 0 to 1.

If working with 2D curves the above vector equation gives two scalar equations for each point on the curve.

Still there is t as an unknown, so you should take 2 more points (4 in total) which will give you 4 unknowns (t for first point, t for second point, x and y of the P1, middle control point) and 4 equation to solve (2 from each sample point).

Solve that with your favourite numerical method and you will get the original curve on which the points came from.

If you still think that you can get more curves and that you will have to choose something then you are not working with bezier curves, but with bezier splines (in a sense of multiple curves joined together). Still the same principle applies and if you work out a way to solve a single curve from the above equations (and if you have enough points) then you can divide the problem into n-segments of actual bezier curves and solve each as outlined above.

If it turns out that you don't have enough points then look at the linked article again - you are probably looking for the smoothest curve and there are some suggestions in the article on how to get there as looking for the exact solution (shortest curve/smoothest curve) seems to be rather complex.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文