Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// IFMP - Challenge Lindenmayer // Author: Christiane Goltz // Prog: GoltzChristiane2.cpp // Draw turtle graphics for the Lindenmayer system with // productions X -> +FX-, Y -> -FY+XY, initial word XY // and rotation angle 77 degrees #include #include // necessary: x and y call each other void y (const unsigned int i); // POST: w_i^X is drawn void x (const unsigned int i) { int angle = 77; if (i > 0) { ifm::left(angle); // + ifm::forward(); // F x(i-1); // w_{i-1}^X ifm::right(angle); // - } } // POST: w_i^Y is drawn void y (const unsigned int i) { int angle = 77; if (i > 0) { ifm::right(angle); // - ifm::forward(); // F y(i-1); // w_{i-1}^Y ifm::left(angle); // + x(i-1); // w_{i-1}^X y(i-1); // w_{i-1}^Y } } int main () { std::cout << "Something around 15 is best. Number of iterations =? "; unsigned int n; std::cin >> n; x(n); y(n); return 0; }