Differential Geometry and Spiro Spline Interpolation

Like differential calculus, differential geometry is difficult. Aside being difficult, sometimes it doesn't provide a better answer than what a five year old could give you. "You can't wrap that sphere into a paper without wrinkling the paper!" You get the same answer, just as an integral or differential much harder to understand. It's still a good tool for reasoning about these difficult subjects though.

When it comes to computing, there's nothing new to approximation. You commonly represent real numbers as floating point values on a computer. Just adding or subtracting values represented these ways are intrinsically approximate. Often the approximate results work just as well as the exact values. Very often the input or even the output isn't exact anyway. If you get the answer correct within the tolerance you accept or can afford to compute, it's good enough.

Differential geometry models physical things well. It expects everything can be divided into infinitely small pieces. Even if it were not true, it describes things we can measure well. Vectors and matrices, that can be thought to be bundles of vectors, model flat spaces in relation to others flat spaces and objects in that space. Mathematics used in this way represent observations made about the world.

Raph Levien's Spiro Splines

In Raph Levien's Spiro Splines, the curvature and angle are defined as a polynomial over the arc's length. Therefore we can directly calculate the starting and ending angle of the arc. When we integrate the arc from starting point to the ending point, we will know how far apart the end points are, given arc of length 1. The curvature is relative to the distance we travel on the curve, so we can downscale the arc and position it between the chord we want to travel with it.

It is sufficient to compute the spiro integral as definite over -0.5, +0.5. This simplifies the math needed to approximate the function, but still allows the whole spline to be interpolated. Since the spline is defined as a polynomial, we can shift and scale the polynomial before we evaluate the integral. This means we are able to compute the whole integral on any range! The result is normalized over arc length of 1 thought, so it presents the situation as if we had travelled over the arc length of 1. It is also always rotated about the half of the angle travelled over the distance, because the function represents travel from -0.5 to +0.5.

Spiro curves have several pleasant properties. Similar to beziers we can subdivide them without restrictions. After the subdivision we know how much of a bend the distance represents, allowing us to adaptively subdivide the shape for rendering. But unlike beziers, Lot of interesting properties of the curve are obvious: arc length, curvature on end-points, change of curvature along the curve.

These properties allow to construct a constraint solver for the whole curve. I yet have to study the solver closer to explain how it works though. I know Newton's method is involved there. I saw a Jacobian or two fly too.

Raph's curves only maintain their properties when kept on a plane. Generalizing them for space curves and space surfaces, although valuable, might be very expensive. I'll try that, and bunch of other things later on. Raph represents several other good primitives. I'd believe, iff given enough expertise about the subject, Raph's method to implement these curves would be very straightforwardly generalizable.

Term Rewriting Systems

I found Raph's source code extremely unreadable at the focal and the most important point. It seems this is the result of expanding the integrals and equations, then dropping them into the code I happened to read. From language implementor's viewpoint, that's a failure in metaprogramming. There's a python script somewhere Raph used to expand the integrals. Constructing the program directly from the equations presented in the thesis should be practical. That it is not, means that our programming languages suck.

Studying on, I found something about Knuth-Bendix Completion Algorithm. It seems something relevant for my programming language project.

Similar posts