Background
I’m doing exercise 4.9 of Think Julia, which asks for a function for a polar rose using Luxor’s turtle graphics.
Difficulties
- Work out the geometric structure of the family of polar roses. The key is
to construct some auxiliary isoceles triangles and work out the angles between
them. One sees that they are parametrized by two varaibles
nandk.n: number of petalsk: petal increment- constraint:
k โ n รท 2
- Handle the case when
gcd(n, k) > 1, i.e. more than one closed loop. - The positive
xdirection goes to the right; the positiveydirection goes down.
Attempt
- Use
ThinkJulia.Reposition(t::Turtle, x, y)to reposition the turtle. - Use
turn(t::Turtle, ฮธ)to turnt - Use
ThinkJulia.Orientation(t::Turtle, ฮธ)to restore the turtle’s orientation after the move.
Code
I spend three days writing and testing this function.
[Read More]