贝塞尔曲线和法国曲线
我正在使用贝塞尔曲线在我正在制作的程序中绘制曲线。我有五点。 这是我试图创建的曲线的粗略草图。我正在尝试制作一条经过 A、B、C、D 的曲线。然而,C 并不是一个确定的点,它是曲线应该穿过哪里以使其看起来像法国曲线的建议。 C 以 45 度从 E 出来。
有人对如何做有任何建议吗近似穿过这些点的法国曲线?
I am using Bezier curves to plot curves in a program I am making. I have five points.
Here is a crude sketch of the curve I am trying to create. I'm trying to make a curve that goes through A,B,C,D. However, C is not a definite point, it is a suggestion of where the curve should pass through to make it look like a French Curve. C comes out from E at 45 degrees.
This is an illustration of what I am trying to do.
Does anyone have any suggestions on how to approximate a French Curve that would go through those points?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用三次贝塞尔曲线。三次贝塞尔曲线由四个点定义,但不经过中间的两点,它们仅指定贝塞尔曲线的向量。对您来说不幸的是,有无限数量的三次贝塞尔曲线可以“穿过”您的四个点。
Don Lancaster 就此撰写了文档 (pdf)。其中涉及到有关他使用的算法的一些非常有趣的细节。这是在后记中,我怀疑你正在使用它,但至少原理在那里。
这是一篇关于 CodeProject 的文章,他们在其中构建了一个库来执行此操作你想用 C# 做什么。
You need to use a Cubic Bezier. Cubic Beziers are defined by four points, but do not pass through the middle two points, they merely specify a vector for the Bezier. Unfortunately for you, there are an infinite number of Cubic Bezier curves that can go 'through' your four points.
Don Lancaster has written a document (pdf) about this. Which goes into some pretty interesting detail about the algorithms he use. It's in postscript which I doubt you're using, but at least the principals are there.
Here is an article out on CodeProject where they've built a library for doing what you're trying to do with C#.
贝塞尔曲线穿过指定的第一个和最后一个控制点,内部控制点决定形状。如果您使用 ABCDE 制作一条曲线,它将不会通过点 C。但是您可以将其分成两条不同的曲线,在 C 之前和之后引入一个控制点,这样您就有 AB B' C 和 C C' D E。制作 B', C 和 C' 共线,使得曲线具有一阶连续性。
Bezier curves pass through the first and last control point specified, and the interior control points determine the shape. If you make a curve using ABCDE it will not pass through point C. But you could break it into two different curves, introducing a control point before and after C so you have A B B' C and C C' D E. Make B', C, and C' collinear so that the curve will have first order continuity.
给定任意三个不共线的点(A、B、D),您可以绘制一条连接它们的圆弧。
给定任何三个或四个点,您可以构建一条连接它们的贝塞尔曲线,看起来相当漂亮。 (您可能不需要仅仅为了让曲线看起来漂亮而添加一个额外的点 C,但是如果您愿意的话当然可以。)
具体如何执行此操作取决于您所使用的图形库。那么你使用什么库?
Given any three non-collinear points (A, B, D), you can draw an arc connecting them.
Given any three or four points you can construct a Bézier curve connecting them that looks rather nice. (You probably do not need to throw in an extra point C just to get the curve to look nice, but of course you can if you want.)
Precisely how to do this depends on the graphics library you're using. So what library are you using?
上面所说的一切都是事实,但是我最近发现了一个小技巧。贝塞尔曲线不会通过控制点,除了 p0 和 pn (第一个和最后一个)。但是有一个公式可以让你构造贝塞尔曲线通过给定点的曲线。您可以通过计算新的“假想”控制点来做到这一点。遗憾的是,我只有二级曲线的公式,但我确信它可以推广。这里是:
新点(X)=P1(x)*2-(P0(x)+P2(x))/2
对于 Y 同样,
这个公式给出“新”P1 点(因为 p0 和 p2 是起点和终点),并且曲线穿过“原始”P1。希望有帮助吗?还使用 Bernstain 多项式进行计算,这是我的建议
Everything said above is truth,but there is a small trick that i just found about recently.Bezier curves DO NOT pass through control points,execpt p0 and pn (first and last).But there is a formula that enables you to to construct bezier curve through given points.You do that by calculating new "imaginary" control point.Sadly,i only have formula for 2nd degree curves,but im sure it can be generalised.Here it is:
NEWPOINT(X)=P1(x)*2-(P0(x)+P2(x))/2
same for Y
this formula gives "new" P1 point (cause p0 and p2 are start and end),and curve pass through "original" P1.Hope that helps?Also use Bernstain polynoms for calculation,thats my advice