Journal Archive About the Journal
The Beautiful Walk of the Penguin
Journal entry for 14 Jun 2010 | Link
In Pynguin, a Python implementation of turtle graphics, one can write a function that takes an angle and a length, points the penguin at the given angle, and draws a line of the stated length.

Easy enough.

vector(120,100)
Using vector(), one can write a function that takes an an angle and a length, draws a line at that angle times 0, then a line at that angle times 1, then 2, and keeps going indefinitely. ("turn += 1" is the same as "turn = turn + 1".)

This will result in polygons of various kinds depending on what angle you feed into the function. (After a while the penguin starts drawing over old lines.) If the angle is 90° you get a square.

poly(90,100)
At 120° you get a triangle.

poly(120,100)
60° is a hexagon.

poly(60,100)
144° is a five-pointed star.

poly(144,100)
80° is a nine-pointed star. (80 * 9 = 144 * 5 = 720, which tells you something about stars.)

poly(80,100)
A turn of one and a length of one plugged into this function results in a circle. (Really, a 360-sided polygon, but close enough for a penguin.)

poly(1,1)
We can alter poly() to take two different vectors, draw the first, draw the second, and then increment the multiplier on the angle as before.

This allows us to ask a question: what do you get when you cross a triangle with a square? (Which I guess we could ask anyway, but this allows us to ask with a reasonable expectation of an answer.)

duopoly(120,100,90,100)
How about a triangle with a five-pointed star?

duopoly(120,100,144,100)
An octogon with a square?

duopoly(40,100,90,100)
A circle with a five-pointed star?

duopoly(1,3,144,100)
A circle with a hexagon?

duopoly(1,2,60,100)
A striking thing comes to pass when you cross a circle with a larger circle drawn in the opposite direction.

duopoly(1,1,-1,3)
It turns out that crossing circles with anti-circles makes many lovely shapes.

duopoly(1,2,-2,3)

duopoly(1,2,-4,5)

duopoly(1,2,-6,7)

duopoly(1,-1,-9,9)
The moral of the story is have a nice day.