我可以从全bezier半贝塞尔? [英] Can I make a half-bezier from full bezier?

查看:222
本文介绍了我可以从全bezier半贝塞尔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以JavaScript绘制的典型立方贝塞尔曲线(此示例为googled ...)
http ://jsfiddle.net/atsanche/K38kM/

Take a typical cubic bezier curve drawn in JavaScript (this example I googled...) http://jsfiddle.net/atsanche/K38kM/

具体来说,这两行:

context.moveTo(188, 130);
context.bezierCurveTo(170, 10, 350, 10, 388, 170);

我们有一个立方贝塞尔曲线,起始 188,130 ,结束于 388,170 ,并且具有控制点a: 170,10 和b: 350,10

We have a cubic bezier which starts at 188, 130, ends at 388, 170, and has controls points a:170, 10 and b:350, 10

我的问题是可以通过数学方法调整终点和控制点另一条曲线只是原始曲线的一部分?

理想的结果是能够从开始采取贝塞尔曲线的百分比,其中0.5只绘制贝塞尔曲线的一半,0.75绘制大部分贝塞尔曲线(等等)

The ideal result would be able to able to take a percentage slice of the bezier from the beginning, where 0.5 would draw only half of the bezier, 0.75 would draw most of the bezier (and so on)

我已经完成了De Castelau的几个实现这允许我在[0 ... 1]之间跟踪贝塞尔曲线的轮廓,但是这不提供一种方法来数学地重新计算贝塞尔曲线的结束和控制点以形成亚贝塞尔曲线...

I've already gotten working a few implementations of De Castelau which allow me to trace the contour of the bezier between [0...1], but this doesn't provide a way to mathematically recalculate the end and control points of the bezier to make a sub-bezier...

提前感谢

推荐答案

De Casteljau确实是一种算法。对于由4个控制点P0,P1,P2和P3定义的三次贝塞尔曲线,子贝塞尔曲线(0,u)的控制点为P0,Q0,R0和S0,以及子贝塞尔曲线的控制点(u,1)是S0,R1,Q2和P3,其中

De Casteljau is indeed the algorithm to go. For a cubic Bezier curve defined by 4 control points P0, P1, P2 and P3, the control points of the sub-Bezier curve (0, u) are P0, Q0, R0 and S0 and the control points of the sub-Bezier curve (u, 1) are S0, R1, Q2 and P3, where

Q0 =(1-u)* P0 + u * P1

Q1 =(1-u)* P1 + u * P2

Q2 =(1-u)* P2 + u * P3

R0 =(1-u)* Q0 + u * Q1

R1 =(1-u)* Q1 + u * Q2

S0 =(1-u)* R0 + u * R1

Q0 = (1-u)*P0 + u*P1
Q1 = (1-u)*P1 + u*P2
Q2 = (1-u)*P2 + u*P3
R0 = (1-u)*Q0 + u*Q1
R1 = (1-u)*Q1 + u*Q2
S0 = (1-u)*R0 + u*R1

请注意,如果您想从原Bezier曲线中提取一个线段(u1,u2),则必须两次应用De Casteljau。第一次将在参数u1处将输入贝塞尔曲线C(t)分裂成C1(t)和C2(t),并且第二次将必须在调整的参数u2 * =(u2 -u1)/(1-u1)。

Please note that if you want to "extract" a segment (u1, u2) from the original Bezier curve, you will have to apply De Casteljau twice. The first time will split the input Bezier curve C(t) into C1(t) and C2(t) at parameter u1 and the 2nd time you will have to split the curve C2(t) at an adjusted parameter u2* = (u2-u1)/(1-u1).

这篇关于我可以从全bezier半贝塞尔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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