October 16th, 2012 is technically Ada Lovelace Day, a day for celebrating women in science, technology, engineering, and math (STEM), but as long as it's October 16th *somewhere* you can celebrate the day. Ada Lovelace is known as the first computer programmer, and possibly the first person to have a code review, finding bugs in Charles Babbage's code:
So also was the algebraic working out of the different problems, except, indeed, that relating to the numbers of Bernoulli, which I had offered to do to save Lady Lovelace the trouble. This she sent back to me for an amendment, having detected a grave mistake which I had made in the process.
-- Charles Babbage in his Passages from the Life of a Philosopher
I can only hope Ada's letter started out in the traditional code review lexicon "WTF Charles!?"
Though as a programmer Ada's impact on me is great, I'd have to say Mary Everest Boole had an earlier impact on my, though I didn't know it was her at the time. In 5th grade I was shown a method of creating line art with algebra, commonly known as curve stitching or string art. It's an unfortunate label, as it hides the fact its really a method for constructing quadratic Bézier curves.
The process is simple. Draw to lines connected at one point, and then draw a series of lines connecting two lines offsetting a little bit each time. Here is a video of the process:
As someone who has never been talented at graphic design and art I loved filling notebooks with curve stich designs. Mostly faces, spaceships, and futuristic landscapes. You can really get interesting patterns as you vary the line lengths, angles, or use arcs in place of the lines.
Curve stitching was invented by Mary Boole (yes, wife of that Boole) as a way to engage children in mathematics. Mary actually spent quite a bit of time working on ways to improve mathematical education by making it more approachable. Some of her books like the Philosophy and Fun of Algebra and The Preparation of the Child for Science are still around, though searching it looks like many may have been lost to time. That's unfortunate, because getting children interested in mathematics is a problem we have yet to solve over 100 years later.
A few years ago, in one of those odd moments when you start a new program just to works something out, I created a little WPF app that does curve stitching. It's basic, and I've not touched it since, but all the user has to do is click three points on the screen to render a pattern. Repeat as often as you like and press escape to clear the screen. You can get the code in my Google Code project.

The code to draw a curve stich is pretty simple. The method below takes in the 3 points that define the two lines, the number of lines to draw connecting them, and a WPF Canvas object to render them on.
public void DrawLineArt(Point start, Point center, Point end, Int32 steps, Canvas graph) {
Line source = new Line() { X1 = center.X, Y1 = center.Y, X2 = start.X, Y2 = start.Y, Stroke = Brushes.Black, StrokeThickness = 1 };
Line target = new Line() { X1 = center.X, Y1 = center.Y, X2 = end.X, Y2 = end.Y, Stroke = Brushes.Black, StrokeThickness = 1 };
graph.Children.Add(source);
graph.Children.Add(target);
for (Int32 i = 1; i <= steps; i++) {
Line connection = new Line() { Stroke = Brushes.Black, StrokeThickness = 1 };
connection.X1 = source.X1 + (source.X2 - source.X1) / (Double)steps * i;
connection.Y1 = source.Y1 + (source.Y2 - source.Y1) / (Double)steps * i;
connection.X2 = target.X1 + (target.X2 - target.X1) / (Double)steps * ((Double)steps - i);
connection.Y2 = target.Y1 + (target.Y2 - target.Y1) / (Double)steps * ((Double)steps - i);
graph.Children.Add(connection);
}
}
I've toyed around with ideas to make a game using only this style of line art for the graphics. It's a shame we no longer have vector rendering CRTs as we did in the days of Tempest. I think the part of this game that appeals most to me wouldn't be the game itself, but making the modeling program for creating the game assets!
Can't you just see this guy as a boss battle?

Posted By Mike On Monday, October 15, 2012
Filed under wpf games math |
No Comments