Calculating Bezier curve length and approximating its length function

chebyshev polynomialsquadrature

I hope you can help me. I'm working with $N$th order Bezier curves $\mathbf{C}(t)$, and so far I have used Gauss-Legendre (GL) to calculate the length of the curve $s(t_1, t_2)$. Having the abscissae and weights precomputed up to $N_{gl} = 64$, I used a naive (and pretty much random) heuristic to determine the number of points for the Gauss-Legendre:
\begin{equation}
N_{gl} = \min\left(N\left\lceil{\frac{t2-t1}{0.2}}\right\rceil, 64\right)
\end{equation}

The drawback is that usually this is overkill, and only in some extreme cases is it a necessity.

For the efficiency, I tried the approximation of $s(t)$ by the Chebyshev polynomials, where I evaluated $s(0, t)$ at Chebyshev nodes with the aforementioned GL. It works superbly, but it is slow when evaluating length at nodes.

Currently, I'm looking into changing GL for Clenshaw-Curtis (CC), with an adaptive strategy (doubling the number of Chebyshev nodes to reuse previously computed ones until sufficient precision is met). I like it more than GL since I can also precompute abscissae and weights, but I can also set the wanted error tolerance.

Now I'm wondering, since I have already computed $||\mathbf{C}'(t)||_2$ at Chebyshev nodes for CC, can I reuse them for calculating approximation of $s(t) = \int_0^t ||\mathbf{C}'(x)||_2 dx$ by Chebyshev polynomials? (I.e., reuse them to somehow calculate length of the curve between Chebyshev nodes)

Best Answer

Personally, I’d avoid these sophisticated numerical integration functions.

Just use piecewise linear approximation, instead. Calculate points on the Bézier curve at 100 $t$ values, and use these points to construct a polyline, and calculate its length. Then calculate 200 points, and do the same thing. Keep increasing the number of points until the length converges satisfactorily.

The only possible problem is performance. There are clever ways to calculate the array of points (using forward differencing) that can substantially reduce the computations required. But, on a modern computer, I wouldn’t expect performance to be a problem, anyway.

If you really want to use numerical integration, then this blog post is a good place to start.

Related Question