I’m thinking of building a robot that suspends a whiteboard marker from two strings, and draws on a whiteboard. There would be two motors that can change the length of the strings.

I was playing with some calculations for this robot, literally on the back of an envelope. I need to calculate how long each string will be for a particular coordinate.

Pythagoras’ theorem gives:

and

If we smash them together, we get:

and of course

That was easier than I expected – the maths wasn’t too hard! This should be enough to draw short segments with linear interpolation.

But, I’d like to know how the string length changes as I draw a straight line. Imagine a line being drawn perpendicular to the string; when the length of the string gets very long, it should lengthen at the same rate as the line. This suggests that the string length and the line length forms a hyperbola.

Consider a horizontal line beneath one of the wheels. Let *x* be the distance from the closest point on the line to the wheel. *s* is the string length. If the line went through the wheel, the graph

would give the line where the *x* position is the same as the string length.

If the line does not pass through the wheel, this equation from earlier where *r* is the wheel radius and *y* is the shortest distance from the wheel to the line:

can become

which should produce a hyperbola. When the string is long enough, *y²-r²* becomes negligible.

Previously I’ve implemented Bresenham’s algorithm to interpolate values on an AVR; it would be nice to do the same thing to calculate this parabola while drawing a straight line segment. It turns out someone has worked out how to use calculations like this for hyperbolae.