A classic question. The short answer is that using a pre-calculated arc length look-up table (LUT) with a binary search is a standard and very effective method for resolution-independent sampling of a Bézier segment’s arc length.
Due to the mathematical nature of Bezier curves, there isn’t a “lighter” way to achieve the same quality of results.
For cubic and higher-order Bézier curves, there’s no direct mathematical formula to calculate the arc length for a given t value. The relationship between the parameter t and the actual distance along the curve is not linear. This means that stepping through t at a constant rate will produce points that are not evenly spaced. So, any method that aims for uniform spacing must use some form of approximation or pre-calculation.
Corves that have that properties are:
PH Curves (special subset of Bezier):
Euler Spirals (used for railroad and street planning):
Thank you.
That’s what i thought & it looks i’m not far from it, nevertheles it would be interesting to see if there is still room for optimization or better aproach in the implementation itself.
My goal is to use bezier curves in my Timeliner and get rid of Tweener curves if possible.
I was involved with the Kairos Interpolators and the Tranistion Runtime in vvvv.
I might not be aware of the crazy 2d timeline you are about to create, but the classic timeline where time is to the right and value is upwards, you typically don’t have the ArcLength issue, but another one that is quite related.
You typically want the user to feel at home like in a vector drawing application: be able to draw freely and interact normally. You end up with a classic bezier curve in 2d. Bezier(p) -> (x,y). But what the timeline needs is x -> y.
So first you need to some do an inverse bezier starting with dimesion x/t, so that you then have the normal parameter p that alows you to sample in the other dimension y/value.
The implementation of the inverse bezier can again be either some sort of ArcLength-like search or it can be a cubic polynomial equation solver. VL.CoreLib/src/Math/BezierSegmentHelpers.cs
The patch and the node are part of StdLibs. They might not be part of the standard node set, but just wanted to point you to the open source code. As always you could copy the code or go the IsFriend way and couple closely with CoreLib.