The maths behind Spirograph