public void throwBoomerangs (double size, int number, double offset) { System.out.println("throwBoomerangs("+size+", "+number+", "+offset+");"); if (number>0) { // base case boomerang(size); // draw the extra boomerang moveToNextBoomerang(offset); // move in position to draw next pattern throwBoomerangs(size, number-1, offset); // draw next pattern returnToStart(offset); // meet invariant: start and end in same place } }
// draws a boomerang of specified size with inner angle 120 degrees public void boomerang (double size) { System.out.println("boomerang"); rt(60); fd(size); rt(60); fd(size); rt(150); pu(); fd(size * Math.sqrt(3)); pd(); rt(90); }
public void moveToNextBoomerang (double offset) { System.out.println("moveToNextBoomerang"); pu(); fd(offset); pd(); }
public void returnToStart (double offset) { System.out.println("returnToStart"); pu(); bd(offset); pd(); }