(Previously: 2014, 2011, 2010; also, less closely related, 2015)

I tried to smoothen a stroke by shifting each dot toward the Euler spiral (aka clothoid, aka Cornu spiral) determined by its four nearest neighbors. That didn’t work so well: small wiggles were removed, but big ones were magnified.

Which reminds me that I considered naming the project Meander, but then thought no, the point is to *remove* meanders. (For now I’m calling it Thalweg, until a better name occurs to me.)

The flaw in my thinking is that I don’t want *any* Euler spiral, I want one in which curvature changes as slowly as possible: that is, one that is locally very like a circle.

So the logical thing to do is to shift the dot toward the circle defined by *three* neighbors; or rather, since that would introduce an undesirable asymmetry, the circle that fits the two immediate neighbors exactly and misses the next two by equal distances. I haven’t worked out how to do that; I’ll probably simply fit two circles and split the difference.

I’m also working on another approach: fit two curves exactly to alternating dots, and adjust each dot according to the other curve. Though this uses piecewise Euler spirals, I hope the discipline of global constraints will prevent the exuberance seen above.

An Euler spiral that locally resembles a circle is a

longEuler spiral, so the two approaches should be more similar in effect than their mechanics would suggest.I tried using the arc defined by each dot’s two nearest neighbors in each direction; for the end dot, this means a line, and for the next dot a circle; otherwise clothoids. Didn’t help.