Posts

Showing posts from November 25, 2018

Drawing the Peano curve

Image
up vote 12 down vote favorite Introduction In geometry, the Peano curve is the first example of a space-filling curve to be discovered, by Giuseppe Peano in 1890. Peano's curve is a surjective, continuous function from the unit interval onto the unit square, however it is not injective. Peano was motivated by an earlier result of Georg Cantor that these two sets have the same cardinality. Because of this example, some authors use the phrase "Peano curve" to refer more generally to any space-filling curve. Challenge The program takes an input which is an integer n , and outputs a drawing representing the n th iteration of the Peano curve, starting from the sideways 2 shown in the leftmost part of this image: Input An integer n giving the iteration number of the Peano curve. Optional, additional input is des