求贝赛尔 曲线的长度

来源:互联网 发布:淘宝我订购的服务 编辑:程序博客网 时间:2024/06/05 04:21

Quadratic Bezier curves are defined by second order polynominal, andcan be written as
Quadratic BezierCurve, krzywa Beziera st II,
where t is real parameter with values in range [0,1]. P'sare respectively curve starting point, anchor point and the end point.Derivative of the quadratic Bezier curve can be written as
Quadratic BezierCurve dervative, pochodna krzywa Beziera st II.

Length of any parametric (in general length of any well defined curve) curve can be computated using curve length integral.In case of 2nd order Bezier curve, using its derivatives, this integral can be written as
Curve Length Integral, dlugosc krzywej.
To simplify this integral we can make some substitutions. In this case it we will look like this
.
Next after doing some algebra and grouping elements in order to parameter t we will do another substitutions (to make this integral easier)
.

Finally we get simplified inegral, that can be written in form
Integral to calculate, całka do policzenia
This integral can be 'easily' simplified and calculated using relation
target integral, docelowa całka,
but we need to do some more substitutions
.

After doing elementary algebra we finaly get our expression. To calculate length of quadratic Bezier curve with thisexpression all we need arecoordinates of end points and control point. We dont need to use iterative methods anymore.
Quadric Bezier curve length, dlugosc krzywej Beziera st II.

Accuracy of this evaluation

To check accuracy we will evalute length of quadric Bezier curve using previously calculated expression and approximation algorithm.Used algorithm approximates a Bezier curve with a set of line segments and calculates curve length as a sum over lengths of all that line segments.

In this case we will use a series of quadric Bezier curves. All curves have the same end points. For each curve control point is taken from a set ofpoints equally spaced on a circle, with given radius and centered in the middle between end points.

Presented plot shows comparison of curve length calculated using both (our expression and line approximation) methods for a set of Bezier quadriccurves.Green line shows results from approximation method, curve lengths calculated using our expression are drawn withred cross

Implementation

Implementation in c language can look as follows

float blen(v* p0, v* p1, v* p2)
{
v a,b;
a.x = p0->x - 2*p1->x + p2->x;
a.y = p0->y - 2*p1->y + p2->y;
b.x = 2*p1->x - 2*p0->x;
b.y = 2*p1->y - 2*p0->y;
float A = 4*(a.x*a.x + a.y*a.y);
float B = 4*(a.x*b.x + a.y*b.y);
float C = b.x*b.x + b.y*b.y;

float Sabc = 2*sqrt(A+B+C);
float A_2 = sqrt(A);
float A_32 = 2*A*A_2;
float C_2 = 2*sqrt(C);
float BA = B/A_2;

return ( A_32*Sabc + A_2*B*(Sabc-C_2) + (4*C*A-B*B)*log( (2*A_2+BA+Sabc)/(BA+C_2) ) )/(4*A_32);
};
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 九个月宝宝便秘拉不出来怎么办 一岁四个月的宝宝便秘怎么办 热血三国3要塞打不过去怎么办 清香木夏天有黄叶和掉叶怎么办 生完宝宝妊娠纹还在继续疯长怎么办 陌陌不能最小化观看直播视频怎么办 苏州园区公积金密码忘记了怎么办 房产企业申请破产买的房子怎么办 被业务员骗了买了保险怎么办 孩子特别害怕老师严厉的批评怎么办 4k电视看有线电视不清晰怎么办 移动9.9流量4g网用完了怎么办 东方头条验证码已经被注册了怎么办 打王者两个人吵架被夹在中间怎么办 顾客拿过期的食品过来投诉怎么办 老婆总是埋怨我父母我该怎么办? 代款公司如果使用暴力追债怎么办 法院拍卖款分配有疑意怎么办 法院拍卖买到的房子里有户口怎么办 新注册手机邮箱不和电脑同步怎么办 移动4g盒当月流量封顶怎么办 昆仑加油卡密码忘记了怎么办 昆仑银行e盾密码忘记了怎么办 中石化加油卡密码忘记了怎么办 壳牌加油卡密码忘了怎么办 中国石化加油卡密码忘了怎么办 中石化加油卡密码忘了怎么办 中石化加油卡需要密码忘了怎么办 求不熟领导办事送礼不收怎么办 送礼给领导不收好像很生气怎么办 加油卡没有密码加油后锁住怎么办 个人怎么办中石化油卡怎么开公司票 中石化副卡挂失后钱怎么办 中石化的加油卡丢了怎么办 得仕卡过期3年了怎么办 如果在超市买到过期商品怎么办 华润万家买的豆干过期了吃了怎么办 华润万家购物卡过期了怎么办 杜鹃花水浇多了树叶都掉了怎么办 游客行程因天气原因无法进行怎么办 携程旅游途中提前结束行程怎么办