Closed form arc length parametrization is impossible for quadratic Bézier curves
ninjakoa.la
ninjakoa.la
On a somewhat related note: There are of course exceptions to this, such as Pythagorean-Hodograph curves, which do have closed form solutions and would be suitable for a huge number of use-cases. Sadly there's not too many mathematicians working in computer graphics so we just end up with numerical solutions to everything.
I also think Pythagorean Hodograph curves are overrated. Euler spirals, on the other hand, are extremely easy to work with in an arc length parametrization, it's just that you need to compute a "special function" to get back to parametrized land. Fortunately, that's easy enough to compute very accurately using standard numerical techniques.
GPU-Friendly Stroke Expansion - 177 points - 11 days ago - 40 comments https://news.ycombinator.com/item?id=40856431
My main point is that I believe there are tons of excellent numerical techniques just waiting to be discovered. Lately I've been exploring a Chebyshev polynomial basis for the Whewell equation, and I think that'll bear fruit.
(From what I can tell PH curves are rarely if ever used in practice. They were ostensibly developed for CNC machining and robot motion planning, etc., but are there real products or even serious physical research projects implementing them? What they do have going for them is a huge pile of research papers, of highly variable quality – Google Scholar turns up >2,500 entries.)
[1]: https://github.com/Prunt3D/prunt_notebooks/blob/master/Pytha...
[2]: https://link.springer.com/article/10.1007/s00170-022-09463-y
A motion controller for 3D printers (notably with crackle-constrained trajectory planning), and no website since it is still in the early stages.
Interesting question.
Knuth's METAFONT can describe glyphs not simply as filled outlines, but ALSO as strokes of pens shaped by circles, ellipses, and EVEN convex polygons (e.g., a an acute triangular wedge perhaps).
And the description of a METAFONT glyph is all parameterized (it's really a program! -- hence the META) so there's not even an actual outline for a glyph but a tunable family of glyph variations.
METAFONT's model is humanistic as human ideographs and letter forms were (once) scratchings, engravings, and pen strokes. However the shape of movable type, as captured with Bezier splines by TrueType and Postscript outline glyphs, lack a first-class stroking capability.
So could you support the humanistic METAFONT-style approach efficiently in today's world of GPU rendering? Yes, if you could, as suggested above, efficiently convolve a pen's shape with a stroke trajectory.
Circles for pens are no problem; and ellipses are just squished transforms of circular stroking. But (convex) polygonal pens for stroking?
Polar stroking provides a starting framework for such a convolution approach for convex polygonal pens (say, a triangular wedge or other convex polygonal shape). Step in small changes in gradient direction change. Rather than assuming a conventional circular or nib pen shape, snap each tessellated rib to the closest polygonal pen vertex. The result is the polygonal convolution you seek.
So a question almost nobody is asking: What if we could revive METAFONT for the 21st century?
Imagine a Jurassic Park scenario applied -- not to dinosaurs -- but rather to Knuth's Computer Modern.
https://en.m.wikipedia.org/wiki/Computer_Modern
"Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should."
> The arc length of quadratic Bézier curves actually can be computed with a closed form expression.
While indeed true, the article doesn't provide the closed form expression. The curious or unsatisfied reader can find the solution for the 2D case at the top of page 7 of this SIGGRAPH paper:
https://developer.download.nvidia.com/devzone/devcenter/game...
The quadratic function Q(t)=(x,y) is of the monomial form At^2 + Bt + C where A, B, and C are 2D coefficients (see page 5) where A is non-zero.
Simply convert your Bezier quadratic form to monomial form to apply this equation.
This equation still doesn't provide an arc length parameterization, the article's actual focus.
But if you did, say, want to move 26% (or N%, more generally) of the arc length along a quadratic Bezier segment, first compute the total (100%) arc length with the paper's formula (take care doing so as the paper suggests). Then split the Bezier at a halfway guess (try t=0.5). Again use the formula to evaluate the split quadratic. Repeating this in a divide and conquer fashion, you narrow in on the t value very close to 26% (or N%) of the arc length.
2D vector graphics standards expect to dash cubic & quadratic Bezier segments so some practical strategy to provide an arc length parameterization -- even if unavailable in closed form.
Edit: or were they talking about 26 percent of the length as opposed to t = 0.26? that's a different story.
Edit2: Oh, that's just 0.26 times the total length. What am I missing?
A cubic Bezier curve B(t) is a cubic polynomial of t in [0, 1], parameterized by the four control points. Since it is continuously differentiable, its length is the integral from 0 to 1 of the square root of (1 + (B')^2), a quartic. Such an integral is well known to be reducible to the elliptic integrals, which have no closed form.
I believe you're stating the reduction in the wrong direction?
Compare: halting problem being uncomputable tells you nothing about whether you can solve it for a subset of valid programs.
You seem to interpret that as "given any elliptic integral A, there is no closed form for the solution of A". This is false (there are many counterexamples).
What it actually means is "there is no single closed-form that produces the solution of any given elliptic integral". The quantifiers are the other way around.
This is why I brought up the halting problem. There's a similar confusion that often comes up, where people think that it means there's no way to determine if any given program halts. But this is false - the program "let X=5*6" trivially halts, for instance.
What it actually means is that there's no single program that can uniformly determine whether any given input program halts. It's exactly the same situation.
the general elliptic integral corresponding to sqrt(quartic) doesn't have a closed form
I see, so you’re claiming that there is no closed form for the integral of sqrt(quartic). That is a different statement that neither directly implies nor is implied by the statement in the Wikipedia article. Maybe it is true and has been proven though, I don’t know!Yes? That is a reduction in the other direction. It starts off with an elliptical integral, then reduces it to something else. Not the other way around.
However, I would like to point out that the dichotomy closed form <-> numerical methods is somewhat artificial. Even if one could express an arc length parametrization using exp and log, one would still need numerical methods to compute exp and log.
This somehow leads to the next question: What kind of functions are suitable to describe the arc length?
For another approach, expand sqrt(1 + B'(t)^2) in a Chebyshev series and you're off to the races.
Also, while some folks are hyped about Pythagorean-Hodograph curves, I think they’re kinda niche. Euler spirals seem more practical, even if you have to compute a special function for them. Numerical solutions tend to be more stable anyway, especially in cases where a closed form might break down, like near straight lines.