Reputation: 21
How can I calculated the length of a bezier curve programmatically? given 4 points; the ends of the curve and the two control points. Can someone help me with the algorithm please?
Upvotes: 2
Views: 2049
Reputation: 1102
Bézier curve is sum(pi bi,k(u)). You can sample the curve by increment ing the u with very small numbers and calculate the distance between two consecutive points on the curve and add them up. This is the calculation of poly line length that matti also mentioned.
Upvotes: 0
Reputation: 65126
If you know your calculus, you could take the parametric form of the bezier curve off Wikipedia or something and use this:
http://tutorial.math.lamar.edu/Classes/CalcII/ParaArcLength.aspx
to calculate its length. I assume that you tried to google for this before asking, and found out that nobody had posted the solution already.
If you're not into calculus, you can get a reasonable approximation by approximating the curve with a polyline, whose length is easy to calculate.
Upvotes: 2