I recently became aware of Cistercian numerals, a system for writing numbers up to 9999 which was developed in the middle ages by the Order of Cistercians. Personally, I think they have a pleasant geometric form which could be well suited to turtle graphics:
In this series of posts, I’ll walk through one way of teaching the Logo turtle to draw Cistercian numerals in ucblogo (Berkeley Logo). We’ll start with the numbers zero through four and then build up from there, eventually getting to the full range of numbers from 0 to 9999.
Before beginning, I want to clarify a point about terminology. I’ll try to stay consistent in using the following terms:
- number – the idea of a specific quantity (E.G. the concept of seven items)
- numeral – a physical representation of a number (E.G. both “seven” and “7” would be different numerals which represent the same number)
- digit – a single unit of a numeral (E.G. “7” is a digit, “77” is two digits)
This distinction will become more important as we consider numerals with multiple digits in them. For now, it’s something to keep in the back of your mind – we will be revisiting the distinction and refactoring some of the code we write in the first pass to account for it.
The starting point is the central vertical line:
TO Draw.0 FD 120 END
This will be present in all Cistercian numerals and can be used to represent the number zero. Some sources indicate the Cistercians only drew numbers from 1-9999; but, I think it’s fair game in a modern implementation to use this to indicate zero.
Drawing the numeral for one is also fairly straightforward:
TO Draw.1 FD 120 RT 90 FD 40 END
The numeral for two is similarly straightforward; but, with a little extra wrinkle:
TO Draw.2 FD 120 BK 40 RT 90 FD 40 END
In order to draw the numeral three, a little bit of math is required to figure out the length of the diagonal line.
Since we know the length of two of the sides and we know this is a right triangle, the Pythagorean Theorem will help:
a2 + b2 = c2
c = √(a2 + b2)
We can ask Logo to perform the actual calculation for us. The POWER function can be used to square the value by raising it to the second power. The SQRT function can then be used to calculate the square root.
? PRINT SQRT ((POWER 40 2) + (POWER 40 2)) 56.5685424949238
Yielding an answer which can be rounded off to 57 and allowing us to proceed to drawing the numeral for three:
TO Draw.3 FD 120 RT 135 FD 57 END
The numeral for four combines the backward movement we used in drawing the numeral two and the diagonal length we calculated for the numeral three:
TO Draw.4 FD 120 BK 40 RT 45 FD 57 END
This is a good breakpoint as the numeral for five can be drawn with a slightly different approach. While you can certainly draw it as a unique character like the ones above, you can also think of it as the result of combining drawing both four and one:
This is where we’ll start teaching the turtle some new concepts for drawing Cistercian numerals in the next post; but, if you are interested in learning more about Cistercian numerals before then: