立方贝塞尔曲线段 [英] Cubic bezier curve segment
问题描述
如果我有描述贝塞尔曲线P1,P2,P3,P4的4个点(其中P1和P4是曲线的终点,P2和P3是曲线的控制点),我怎么能找到只描述这段贝塞尔曲线的点?
我发现这个答案这正是我正在寻找,但答案似乎是错误的。如果我在应该代表整个贝塞尔曲线的方程中设置t0 = 0和t1 = 1,那么得到的点是无效的。它们不等于原始点。
似乎解决方案与De Casteljau算法有关,但我无法理解它是如何工作的。
是, De Casteljau的算法就是要走的路。
参数化
如果你的曲线从t = 0到t = t = 1没有正确的参数化,那么看起来你正在用错误的方程描述你的曲线。 维基百科对您具有正确的公式:其中,B(b) (1-t)2
[我将维基百科中基于零的表格的索引从您的问题调整为基于一维表格。]
如果你设置 1 。如果你设定 4 。在这之间,曲线的形状由这些点和两个控制点P 2和P 3 确定。 >。 让参数在你想要的位置削减你的曲线。假设你只想保留最初的部分。你从这里到P 画出从P 1 到 2 的三条线> 3 并从那里到 4 。这些线条中的每条线段都是以其长度的分数 到P 。再次做相同的操作以获得两点 123 和 234 ,并再次获得单点< I> P 的<子> 1234 子>。最后一点是B(t),即截断曲线的终点。起始点像前面一样是P 1 。新的控制点是我们刚刚构建它们的方式 移除曲线的初始部分的方式相同。所以在两个步骤中,您可以修剪曲线的两端。您可以获得一组新的控制点,这些控制点恰好(以您使用的数字精度计算)描述的是您的原始曲线的一部分,不包含任何近似值或类似参数。 唉,这看起来并不是一个完美的世界。在撰写本文时,这些公式仅使用二次多项式,因此它们无法在三次曲线上描述端点。正确的公式应该如下: 3 = 4 = 请注意,在括号表达式中,至少有一些这些条款是相同的,可以是c ombined。我相信,我没有这样做,因为这里所述的公式会使模式更清晰。您可以简单地针对 x 和 y 方向独立执行这些计算来计算新的控制点。 If I have the 4 points describing a Bezier curve P1, P2, P3, P4 (where P1 and P4 are the end points of the curve and P2 and P3 are the control points of the curve), how could I find the points that describes only a segment of this bezier curve? I found this answer which is exactly what I am looking for but the answer seems wrong. If I set t0=0 and t1=1 in the equations which should represent the entire bezier curve, the resulting points are not valid. They are not equal to the original points. It seems that the solution is related to the De Casteljau's algorithm, but I can't understand how it works. Yes, De Casteljau's algorithm is the way to go. If your curve isn't correctly parametrized from t=0 trough t=1, then it seems you're using the wrong equation to descibe your curve. Wikipedia has the correct formula for you: B(t) = (1−t)3 P1 + 3(1−t)2t P2 + 3(1−t)t2 P3 + t3 P4 [I adjusted the indices from the zero-based form in Wikipedia to the one-based from your question.] If you set t=0, you get P1, your starting point. If you set t=1, you get P4, your endpoint. In between, the shape of the curve is determined by those points and the two control points P2 and P3. Let t be the parameter where you want to cut your curve. Let's say you want to keep only the initial part. You draw the three lines from P1 to P2, from there to P3 and from there to P4. Each of these lines you divide at a the fraction t of its length, i.e. the length of the line before the dividing point relates to the entire length as t : 1. You now have three new points P12 through P34. Do the same again to obtain two points P123 and P234, and again to obtain the single point P1234. This final point is B(t), the endpoint of your truncated curve. The startpoint is P1 as before. The new control points are P12 and P123 the way we just constructed them. Removing an initial part of the curve works the same way. So in two steps, you can trim both ends of your curve. You obtain a new set of control points which exactly (up to the numeric precision you use) describe a segment of your original curve, with no approximation or similar involved. You can translate all of the geometric descriptions above into algebraic formulas, and in a perfect world you should come up with the results from this answer to the question you quoted. Alas, this doesn't appear to be a perfect world. At the time of this writing, those formulas only used polynoms of degree two, so they could not describe endpoints on a third degree curve. The correct formula should be the following: where u0 = 1 − t0 and u1 = 1 − t1. Note that in the parenthesized expressions, at least some of the terms are equal and can be combined. I did not do so as the formula as stated here will make the pattern clearer, I believe. You can simply execute those computations independently for the x and y directions to compute your new control points. 这篇关于立方贝塞尔曲线段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
De Casteljau算法
$ b
u 0 u 0 u u P 1 +
( 0 0 0) 0 +
0
0 0 u (0 0 0 0 ) 2 +
( t 0
0
t 0
0 u <0> 0 (1)在下面的例子中,我们可以看到, 0 u u u 1 1 +
/ i> 0
u 0 0 ui 0 t 1 1 0 0 1 >) 2 +
(t 0 t > 0 1 > 0
u u u u 1 u u / i> 1 +
(
0 0 1 <=> 1 <=> <2> <2> =
(t <1> i> 0 1 1 1 1 +
< u
1 1 1 1 1 1 1 1 /
(t)= 1 u 1< sub> +
< u> 1< t> 1< u> 1 +
1 1 1 1 (1)其中,P(t)= t 1(t)= t 1 1 1 +
sub> 1 1 1 1 +
t 1< 1>< 1> 1< 1> 1< P< i > 3 +
t 1
Parametrization
De Casteljau's algorithm