Assume I have a cubic bezier curve (whose length I know). How do I split it into equal segments, let's say, three equal segments?
In other words, how do I calculate the t parameters that split it into three equal segments? Splitting at t = 0.33 and t = 0.66 will not produce equal segments. In fact, splitting at any t other than 0.5 on a symmetric curve will not produce equal segments.
Example of t = 0.33 and t = 0.66 on an actual curve:

I havn't any magic equation making the relationship between the length of a Bezier curve from X(0) and X(t).
The best I can propose is to compute the length by integration (by recursivity, dividing the Bezier curve in 2 until it is "tiny"), and afterward, compute the same integration stopping at the interesting distance (a fraction of the first computed distance).
In OCaml, this could be done easily. Note that
bezier_stoptakes 4 points -a,b,c,d- acurrent_length(the length of the Bezier segment beforea) and thethreshold. The idea, is if the desired point is in the Bezier, it will returnReturn twheretis what you want (relative to the current Bezier... the caller will have to scale this value). If the desired point is after thedpoint (your Bezier curve is too short), returnLength lwherelis the length of the current Bezier curve. (SeeLengthandResultas tags which are added to the values).You will find a
Return 0.5which will surprise you. At a very closed neighbour of the desired point (at a point we refused to dig further), we can't have a preciset. It is not important, since the imprecision is divided by 2 each time the recusive function returns. But an interpolation should be more efficient. ((threshold-current_len)/dist)typically). This should make the program usable with an higherepsilon.Here, the program computes
tfor a length 2.0 and len-2.0. Since the proposed curve is symetrical, the sum must be 1.Many addition of length have the same magnitude, this is a good way to improve the precision.
or in Python. The language makes it a little complex to return either a length, either a Returned t. (Here, with two classes).
You have the value of
tinbs1.tandbs2.t. The sum is 1 with a very good precision. You can increaseepsilon. The program will be faster be less precise.