Kam Torus

- XLogo

This draws a Kam Torus. Invented by three people Kalmogorov, Arnold and Moser, hence KAM.

To New
  # set default screen, pen and turtle values
  ResetAll SetScreenSize [400 400] HideTurtle
  SetSC Black SetPC Green SetPS 1 PenUp

To Kam
  Make "Angle 74.5
  For [Orbit 0.2 1.5 0.05] [
    Make "X :Orbit/3 Make "Y :Orbit/3
    Repeat 300 [
      Make "X2Y (Power :X 2)-:Y
      Make "Xnew :X * (Cos :Angle) + :X2Y * Sin :Angle
      Make "Y :X * (Sin :Angle) - :X2Y * Cos :Angle
      Make "X :Xnew
      Dot List :X*300 :Y*300 ] ]

To Go
  New Kam

Kam Torus
Kam Torus

Procedures blue
Variables pink
Comments green
Library gray