// IFMP - Challenge Lindenmayer
// Author: Christiane Goltz
// Prog: GoltzChristiane3.cpp
// Draw turtle graphics for the Lindenmayer system with
// productions X -> +FYF+, Y -> +FX+FYX, initial word X
// and rotation angle 120 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 = 120;
if (i > 0) {
ifm::left(angle); // +
ifm::forward(); // F
y(i-1); // w_{i-1}^Y
ifm::forward(); // F
ifm::left(angle); // +
}
}
// POST: w_i^Y is drawn
void y (const unsigned int i) {
int angle = 120;
if (i > 0) {
ifm::left(angle); // +
ifm::forward(); // F
x(i-1); // w_{i-1}^X
ifm::left(angle); // +
ifm::forward(); //F
y(i-1); // w_{i-1}^Y
x(i-1); // w_{i-1}^X
}
}
int main () {
std::cout << "Try something around 15. Number of iterations =? ";
unsigned int n;
std::cin >> n;
x(n);
return 0;
}