We’re nearing the end of this little diversion on orthogons. We now know that orthogons are in 11 correspondence with orthobraces, and we can efficiently generate orthobraces. The only thing left is to find a way to turn orthobraces into drawings.
I described a way to turn orthobraces into drawings in a previous post, but the drawings it produced were terrible—the edges get smaller and smaller as the algorithm proceeds. For example, given the string XXXXXXVVXV
, the algorithm produced this drawing:
But we’d really like to be able to produce a drawing like this instead:
What kind of drawings do we want in general? Here are my criteria:
 No two edges should intersect or touch (other than consecutive edges touching at a vertex).
 The length of each edge should be a positive integer.
 The sum of all the edge lengths should be as small as possible.
These criteria seem reasonable, to me at least, though one can easily imagine making other choices. For example, some might wish to consider polygons with edges that intersect at a vertex, such as the one shown below.
We could also imagine minimizing the area, rather than the perimeter, of the polygon.^{1} In any case, the idea is that a polygon with these properties should be as small as possible while remaining nonintersecting and with all edges having a common measurement. (The edges all having integer lengths also means that we will be able to create these drawings by gluing together squares.) Let’s call orthogon drawings with these properties good.
Given these criteria, we can ask questions such as the following:
 Given an orthobrace, does a good drawing of it always exist?
 Assuming good drawing(s) do exist, can we come up with an algorithm to generate them?
It is easy to show that (1) is true: first, use the naive orthogon drawing algorithm to produce a lopsided drawing with tiny edges. Now, if the smallest edge has length , scale the whole polygon by a factor of . This results in a polygon with no selfintersections and all integer edges. This proves that at least one such polygon exists; among all such polygons there must be at least one with minimal perimeter.
However, this does not actually give us an algorithm for producing good drawings! That last step of the proof is the problem: just because there must exist some drawing with minimal perimeter doesn’t help us actually find one. In the end, coming up with an algorithm to produce good drawings turns out to be surprisingly tricky, and illustrates a very important principle in mathematics and computer science. Faced with some large problem/task/proof/computation, what we would ideally like to be able to do is to split it into subproblems/subtasks/lemmas/helper functions, then solve/complete/prove/compute each of those subthings independently, and somehow combine the results to come up with an overall result. For example, to compute the product of two matrices, we just have to break it down into a bunch of dot products between two vectors, doing that for each combination of a row and a column, and then put all the results together into a big result matrix. Working with smaller independent pieces and then combining results is a very powerful technique, since it lets us solve problems, do computations, prove theorems, etc. which are much larger than what we would be able to accomplish by attacking them directly.
However, it seems like this approach fails for drawing orthogons! We might imagine something like this: take the orthobrace and break it up into a bunch of substrings; come up with some kind of drawing for each one; then combine the drawings into a drawing for the whole thing. Unfortunately, this does not work, since the length of an edge can be influenced by other features of the orthogon which are far away. For example, look at this polygon:
The top edge has to be very long in order for the polygon to not intersect itself. How do we know how long it has to be? We cannot infer it just by looking at neighboring edges. It is not even due solely to some particular edges on the other side of the polygon. It is in some sense a “global” property of the whole polygon: the way in which all the edges and vertices interact produces the need for the top edge to be long.
Intuitively, it is this “global” nature of deciding on good edge lengths which makes this problem so difficult. In order to decide how long to make each edge, we have to look at all the vertices and edges… and the length we choose for one edge may influence the length of some other edges, which may in turn force us to choose a different length for the original edge! How can we ever make any progress? And even worse, how can we ever hope to know whether some choices we have made lead to a polygon with minimal perimeter?
In my next (and final!) post on orthogons, I will finally explain how we can leverage some amazingly sophisticated software to produce good orthogon drawings!

Can you come up with an example where the minimumarea and minimumperimeter solutions are not the same?↩
Coming from a completely different angle, couldn’t one start with the nonoptimal orthogons generated by the naïve algorithm and apply a dynamic process minimizing some suitablydefined “badness” (or, alternatively, maximizing “beauty”)? If the goal is to produce *sufficiently* beautiful drawing rather than one of *maximal* beauty, one that’s “beautiful enough for all practical purposes”, this strikes me as a worthwhile approach — details are left as an exercise for the reader, of course.
Yes, I think you could do that, and I spent a while thinking about it; the devil is in the details of course. How exactly should the dynamic process work? How do you know you are making the drawing better instead of worse? And how do you make sure the polygon doesn’t intersect itself at any point during the process?
Pingback: Drawing orthogons with an SMT solver  The Math Less Traveled