Example #1
0
void MainWindow::draw_recur(int iterations, Vector2D &vec)
{
  vec.divide_modulus_by(3);

  Vector2D v1 = vec.next_vector();
  v1.rotate(-60);

  Vector2D v2 = v1.next_vector();
  v2.rotate(120);

  Vector2D v3 = v2.next_vector();
  v3.rotate(-60);

  if( iterations - 1 != 0 )
  {
    this->draw_recur(iterations - 1, vec);
    this->draw_recur(iterations - 1, v1);
    this->draw_recur(iterations - 1, v2);
    this->draw_recur(iterations - 1, v3);
  }

  this->draw_vector(vec);
  this->draw_vector(v1);
  this->draw_vector(v2);
  this->draw_vector(v3);
}
Example #2
0
void MainWindow::triangle_recur(int iterations)
{
  Vector2D vec (50, 120, 400, 120);
  Vector2D v1 = vec.next_vector();
  v1.rotate(120);
  Vector2D v2 = v1.next_vector();
  v2.rotate(120);

  /*this->draw_vector(vec);
  this->draw_vector(v1);
  this->draw_vector(v2);*/

  this->draw_recur(iterations, vec);
  this->draw_recur(iterations, v1);
  this->draw_recur(iterations, v2);
}