BezierSegment Sample / Interpolation Limitation

Hi people,
i’m doing a bit of research around curves sampling and i’m facing some limitations.

1. Proper BezierSegment ArcLength Sampler, resolution independent.

  • This can be solvable using ArcLength and Binary search but i’m wondering if there is a lighter way to do it that doesn’t require these extra steps.
  • Am I using the right Bezier nodes? or are there other way to get this functionality?

2. Float64 interpolation mechanism.

  • As i see the generic Lerp node provided in VVVV uses Float32 as interpolation value.
  • Am i underrating the Float32 resolution?

See the attached patch to see what i mean.
BezierCurve Interpolation.vl (59.9 KB)

Thanks

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):

4 Likes

I really like the freya holmèr videos about splines, for me really good explain all the facades of splines.

The Continuity of Splines

The Beauty of Bézier Curves

3 Likes

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.

The typical solution is to go via p this way:

  • InvBezier_for_x(time) -> p
  • and then Bezier_for_y(p) -> value

like shown here:

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.

3 Likes

@gregsn Thank you so much, I knew there was a resolution independent solution for that.

The crazy 1D timeliner

For the mortals:
BezierCurveInterpolation.zip (108.4 KB)

4 Likes