The Connected Perimeter

· [ algorithms, math ] · @pentronik
Connected points

It is now time to consider some more attractive examples to illustrate how, even with only a beginner’s knowledge of computer graphics, it is still possible to draw aesthetically pleasing patterns.

This was fun, and frustrating. Here are my thoughts about working on Exercise 1.8 in (Angell and Griffith, p.17). Get the above file at PlotterFiles.

The objective is to connect all the N points around the perimeter of a circle. The book has a nice listing of the program that draws the figure. And then points out that “if you are using a pen plotter then [the] listing … is not a very efficient way of drawing the pattern.” The next problem (1.9) describes a method referencing the Fibonocci sequence as a way of connecting the points around the perimeter of a square.

Well, I chased that for a while and it really seems to have been a red herring. Or too clever for me. Although I’m really not sure how it connects all the points on a circle when the sequence skips a larger and larger group of numbers as it goes on.

It also distracted me from the relatively simple modification to the listing needed to greatly shorten the trajectory of the pen in the plotter. Here is my pseudo-code of my solution.

For each jump in the range 1 to N-1.
  Go to the point on the perimeter with index 0.
  Draw a line skipping points according to jump.
  Count the lines drawn to ensure they are all drawn.
  If the jump divides evenly into N, when the turtle comes around to the start
    point, move to the next point and continue jumping until back to that point.
    Keep doing that until the number of jumps is equal to N.
  If the next jump lands back on the point that it just came from (all the way
    across, back over the line just drawn for evan N).

You can see the output of the book’s listing, for N=30, in the first tweet (on HP paper). The paper is excellent printer paper, but not up to the task of being hit with a pen in the same place 30 times. It gets pretty roughed up.

I’ll note also that using this algorithm and stopping early has some nice potential for other shapes.

The second tweet has the results of my code (based on the pseudo-code above). It is on the back of some Strathmore 300 series Bristol. It handles it better, and also there is a lot less pick up and put down of the pen. But still, the surface is not perfect. It is the edge points that suffer the most, the central point which also is crossed 30 times isn’t so bad looking.

I would have to say my favorite bits of this are around the central point, and the “eggs” fourth ring from the center. Overall, I quite like it, it’s nice that such a pleasing thing is “easily” accessible. Really looking forward to learning some more things from this book.


While my solution is quite a bit shorter in travel distance than the original listing, I don’t think it quite makes it to the full 50% reduction. I’ll update with some measurements when I get a chance. I have identified some some further improvements that could be made, if necessary, at a later date.

It is not clear that all these features are necessary or will even work if I want to generalize to perimeters of other convex polygons. And draw points along the perimeter of the polygon not equal to or even with the number of vertices of the polygon, and not overdraw the sides of the polygon.

@pentronik    :fountain_pen:


  1. Angell, I.O. and Griffith, G., High-resolution Computer Graphics Using FORTRAN 77, 1987.

    There is lots of good stuff in here. @pentronik

    More Details