1

我正在使用这段代码来计算 [0, 1] 中 s 的三次贝塞尔曲线。我想根据其几何连续性来扩展曲线。我试过只设置 [0, 1] 以外的值,但结果不正确。实际上是否有一种可能的算法来计算贝塞尔点?

pb, pbh, peh, pe 是三次贝塞尔控制点的向量。

*pq = pb*powf(1-s, 3) + pbh*(3*s*(powf(1-s, 2))) + peh*(3*powf(s, 2)*(1-s)) + pe*powf(s,3);

http://imageshack.us/photo/my-images/217/37013437.jpg/

这是我得到的图像。白色曲线是我想要得到的。有 3 条白色贝塞尔曲线相互连接。中心是基于我的代码的曲线。延伸曲线(整个白色曲线大约是中心曲线的两倍)是我想要的。但是,如果我只是用 s 在 [-0.5, 1.5] 范围内的代码构建贝塞尔曲线,我会得到绿色的曲线,它甚至没有通过两个原始控制点。

对于绿线的句柄,我使用了以下代码,它也适用于 [0, 1] 中的 s。p123 是新的绿色左手柄,p234 是新的右手柄。

p12 = (pbh-pb)*s+pb;
p23 = (peh-pbh)*s+pbh;
p34 = (pe-peh)*s+peh;

p123 = (p23-p12)*s+p12;
p234 = (p34-p23)*s+p23;

提前致谢

4

1 回答 1

1

If you don't have any additional information, then the most reasonable kind of extension you can get is in fact the one you obtain by passing arguments s outside the [0,1] range. Obviously, a curve extended in this fashion will contain the original curve, so as your green curve doesn't do so, the computation of the control points must be flawed. I just added formulas for that computation to another answer; they should work for you as well.

In the three-segment white curve, the control points are not symmetric around the junctions. This means that the curve will continue to go in the same direction (as they are on a line), but will change speed (with s interpreted as time) quite suddenly. You cannot achieve that shape with a smooth continuation. So the method described above won't give you the white shape, and you won't be able to obtain that shape at all unless you provide some kind of further information.

于 2012-07-29T00:09:30.893 回答