To calculate the length of a bezier curve, I have been using pyx.
from pyx import path, unit
bez = path.curve(p[0], p[1], p[0], p[1] + d, q[0], q[1]-d, q[0],q[1])
edgelen = unit.tocm(bez.arclen())
where p
and q
are the endpoints of the curve and d
is a vertical offset for the relative position of the two control points. (In my application, the curves are always "upward").
However, I found that this library call for getting the curve length is painfully slow. Are there other python libraries that might have better performance?