Calculate the length of a segment of a quadratic bezier

主宰稳场 提交于 2019-12-01 18:17:13

问题


I use this algorithm to calculate the length of a quadratic bezier: http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/

However, what I wish to do is calculate the length of the bezier from 0 to t where 0 < t < 1

Is there any way to modify the formula used in the link above to get the length of the first segment of a bezier curve?

Just to clarify, I'm not looking for the distance between q(0) and q(t) but the length of the arc that goes between these points.

(I don't wish to use adaptive subdivision to aproximate the length)


回答1:


Since I was sure a similar form solution would exist for that variable t case - I extended the solution given in the link.

Starting from the equation in the link:

Which we can write as

Where b = B/(2A) and c = C/A.

Then transforming u = t + b we get

Where k = c - b^2

Now we can use the integral identity from the link to obtain:

So, in summary, the required steps are:

  1. Calculate A,B,C as in the original equation.
  2. Calculate b = B/(2A) and c = C/A
  3. Calculate u = t + b and k = c -b^2
  4. Plug these values into the equation above.



回答2:


While there may be a closed form expression, this is what I'd do:

Use De-Casteljau's algorithm to split the bezier into the 0 to t part and use the algorithm from the link to calculate its length.




回答3:


You just have to evaluate the integral not between 0 and 1 but between 0 and t. You can use the symbolic toolbox of your choice to do that if you're not into the math. For instance:

http://integrals.wolfram.com/index.jsp?expr=Sqrt\[a*x*x%2Bb*x%2Bc\]&random=false

Evaluate the result for x = t and x = 0 and subtract them.



来源:https://stackoverflow.com/questions/11854907/calculate-the-length-of-a-segment-of-a-quadratic-bezier

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!