bezier icon indicating copy to clipboard operation
bezier copied to clipboard

how to find the 30% of the total line curve length.

Open ztdepztdep opened this issue 2 years ago • 1 comments

how to find the 30% of the total line curve length.

ztdepztdep avatar Jul 07 '22 15:07 ztdepztdep

The current curve length implementation is here: https://github.com/oysteinmyrmo/bezier/blob/master/include/bezier.h#L744

It's a simple, brute force implementation that splits the curve into N intervals and sums the length of each arc. Since t starts at 0.0 and ends at 1.0 by summing all dts you get the total curve length. There is currently no direct function call to achieve what you want. It would require some small changes to the length() function. I may look at it after the summer, but feel free to make a pull request with a function starting at some t1 and ending at some t2, doing the same work as in the current function.

Another approach could be to use the split(float t) function at https://github.com/oysteinmyrmo/bezier/blob/master/include/bezier.h#L770 and split the curve at t=0.3 and calculate the total length of the left part of the resulting curves, if this is what you need. Would that work?

oysteinmyrmo avatar Jul 12 '22 19:07 oysteinmyrmo

Closing due to inactivity.

oysteinmyrmo avatar Oct 09 '22 09:10 oysteinmyrmo