Sunday, 2011 July 10, 08:47 — curve-fitting

blending curves

I made some progress on an old project: to make outline fonts based on some favorite old bitmap fonts, by automatic fitting of smooth curves to the sequences of dots.
a letter of PLATO IV's standard charset, with curves superimposed
(The image above is in Scalable Vector Graphic format. If you see nothing, you may – dare I say it – need to update your browser. It works in Firefox 5, Safari 5, Chrome 12, Kindle.)

Each arc is a parametric curve of the form z=integral(exp(i·F(t))), where F is a real-valued polynomial. (I use a Taylor series for the integral.)

When F is linear, the curve is a circle. When F is quadratic, the curve is called a clothoid or Cornu spiral or Euler spiral; besides æsthetic design, such curves are much used for railroads and highways, where abrupt changes in lateral acceleration are unwelcome.

The black arcs are circles, passing through maximal sequences of dots. Where two black arcs share dots, I join them with a red arc. For a smooth join, F (the tangent angle) and its first derivative (the curvature) must match. Red arcs are joined by green, then blue, brown, teal.

I stalled in November when I couldn’t see how to blend the arcs; this week I had a new idea, which works better than I expected. The collection of constraints requires F in the blending arcs to be quartic (fourth-power polynomials), and I was afraid that they’d be too wiggly.

Some flaws remain:

A long blending arc sometimes misses its dots, failing the project’s primary criterion; I commented out the test for this, because it regularly crashes for a reason that so far eludes me.

Some glyphs have unnecessary wiggles; for a mild example, in this ‘s’ a red-green segment at the top looks too flat. A future version will consider many composite paths in parallel, choosing that which minimizes the first derivative of curvature (second derivative of F).

Subscribe without commenting

RSS feed for comments on this post.

Leave a comment