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: GoltzChristiane1.cpp // Draw turtle graphics for the Lindenmayer system with // productions X -> +FX-, Y -> -FY+XY, initial word X // and rotation angle 111 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 = 111; 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 = 111; 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 << "Big numbers are best - around 300 or more. Number of iterations =? "; unsigned int n; std::cin >> n; // draw w_n = w_n^X x(n); return 0; }