中点已知的三次贝塞尔曲线的计算 [英] Calculation of cubic Bézier with known halfway point

查看:136
本文介绍了中点已知的三次贝塞尔曲线的计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道:

  • 控制点a和d(二维三次方贝塞尔曲线的起点和终点)

  • The control points a and d (start and end point of a 2D cubic bezier curve)

a-> b,c-> d和b-> c(b,c其他控制点)的斜率

The slopes a->b, c->d, and b->c (b,c the other control points)

贝塞尔曲线的中点在哪里.

现在,有了这些信息,控制点b和c的位置的公式是什么?

Now, given this information, what is the formula for the positions of control points b and c ?

推荐答案

我知道这个问题很旧,但是没有提供正确或完整的答案,所以我认为我可以提出一个解决方案.请注意,David的计算包含多个错误,即使纠正了这些错误,他的解决方案也不完整.

I know this question is old, but there is no correct or complete answer provided, so I thought I'd chime in with a solution. Note that David's calculations contain several errors and his solution is incomplete even if these errors are corrected.

首先,使用三个斜率定义向量T0T1T2:

First, define vectors T0, T1 and T2 using the three slopes:

T0 = ( b - a ) / u0
T1 = ( c - b ) / u1
T2 = ( d - c ) / u2

如果我们知道每对控制点之间的方向距离,那么我们就不需要比例因子u0u1u2 .因为我们只知道斜率,所以u0u1u2是未知的标量.此外,我们假设u0u1u2由于定义了斜率,所以不为零.

If we knew both the direction and distance between each pair of control points then we would not need the scale factors u0, u1 and u2. Since we only know slope then u0, u1 and u2 are unknown scalar quantities. Also, we assume that u0, u1 and u2 are nonzero since slope is defined.

我们可以用几种不同的方式重写这些等式,以获得每个控制点相对于其他控制点的表达式.例如:

We can rewrite these equations in several different ways to obtain expressions for each control point in terms of the other control points. For example:

b = a + T0*u0
c = b + T1*u1
d = c + T2*u2

该问题还指出,我们具有三次贝塞尔曲线的中点".我的意思是说,我们的点位于曲线参数范围的中点.我将这一点称为p:

The question also states that we have the "halfway point" of the cubic Bezier curve. I take this to mean we have the point at the midpoint of the curve's parameter range. I will call this point p:

p = ( a + 3*b + 3*c + d ) / 8

用左侧的未知字符进行重写会产生:

Rewriting with unknowns on the left hand side yields:

b + c = ( 8*p - a - d ) / 3

我们现在可以使用较早的表达式以各种方式替换bc.事实证明,当我们有平行向量T0T1T2时,就会出现歧义.有四种情况需要考虑.

We can now substitute for b and c in various ways using the earlier expressions. It turns out that ambiguities arise when we have parallel vectors T0, T1 or T2. There are four cases to consider.

情况1:T0T1

Case 1: T0 is not parallel to T1

替换b = a + T0*u0c = a + T0*u0 + T1*u1并求解u0u1:

2*T0*u0 + T1*u1 = ( 8*p - 7*a - d ) / 3

这是两个等式,两个未知数,因为T0T1是向量.将u0u1替换回b = a + T0*u0c = a + T0*u0 + T1*u1,以获得缺少的控制点bc.

This is two equations and two unknowns since T0 and T1 are vectors. Substitute u0 and u1 back into b = a + T0*u0 and c = a + T0*u0 + T1*u1 to obtain the missing control points b and c.

情况2:T1T2

Case 2: T1 is not parallel to T2

替换c = d - T2*u2b = d - T2*u2 - T1*u1并求解u1u2:

T1*u1 + 2*T2*u2 = ( a + 7*d - 8*p ) / 3

案例3:T0T2

Case 3: T0 is not parallel to T2

替换b = a + T0*u0c = d - T2*u2并求解u0u2:

T0*u0 - T2*u2 = ( 8*p - 4*a - 4*d ) / 3

情况4:T0T1T2都是平行的

Case 4: T0, T1 and T2 are all parallel

在这种情况下,abcd都是共线的,并且T0T1T2都等效于比例因子.没有足够的信息来获得独特的解决方案.一种简单的解决方案是通过设置u0 = 1来简单选择b:

In this case a, b, c and d are all collinear and T0, T1 and T2 are all equivalent to within a scale factor. There is not enough information to obtain a unique solution. One simple solution would be to simply pick b by setting u0 = 1:

b = a + T0
(a + T0) + c = ( 8*p - a - d ) / 3
c = ( 8*p - 4*a - d - 3*T0 ) / 3

存在无限数量的解决方案.本质上,选择b定义c或选择c将定义b.

An infinite number of solutions exist. In essence, picking b defines c or picking c will define b.

扩展到3D

这个问题专门询问了平面Bezier曲线,但是有趣的是,将这个问题扩展到非平面3D三次方Bezier曲线时,点p是不必要的.在这种情况下,我们可以简单地针对u0u1u2求解此方程:

The question specifically asked about planar Bezier curves, but I think it's interesting to note that the point p is not necessary when extending this problem to a non-planar 3D cubic Bezier curve. In this case, we can simply solve this equation for u0, u1 and u2:

T0*u0 + T1*u1 + T2*u2 = d - a

这是三个方程式(向量为3D)和三个未知数(u0u1u2).替换为b = a + T0*u0c = b + T1*u1c = d - T2*u2会生成bc.

This is three equations (the vectors are 3D) and three unknowns (u0, u1 and u2). Substitution into b = a + T0*u0 and c = b + T1*u1 or c = d - T2*u2 yields b and c.

这篇关于中点已知的三次贝塞尔曲线的计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆