Exemplo n.º 1
0
void triline(turtle_t &turt, double length)
{
   if (length <= 0.01)
   {
      turt.forward(length);
   }
   else
   {
     double newlength = length/3.0;
     triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);
     turt.turn_right(120);
     triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);
   }
}
Exemplo n.º 2
0
//Drawing a Koch Snowflake
void koch(turtle_t &turt, double x)
{
   turt.reset();
   turt.clear();
   turt.set_pos(-0.3, 0.5);
   turt.turn_right(30);

   for (int i = 0; i<3; i++)
     {
       triline(turt, x);
       turt.turn_right(120);
     }
}
Exemplo n.º 3
0
void triline(turtle_t &turt, double length, bool arg)
{
    double newlength = length/4.0;
   if (length <= 0.03)
   {
      turt.forward(length);
   }
   else if (arg)
   {
    
     /*triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);
     turt.turn_right(120);
     triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);*/
	 triline(turt, newlength,true);
	 turt.turn_left(60);
	 triline(turt, newlength,false);
	 turt.turn_left(60);
	 triline(turt, newlength,true);
	 turt.turn_right(60);
	 triline(turt, newlength,false);
	 turt.turn_right(60);
	 triline(turt, newlength,true);
	 turt.turn_right(60);
	 triline(turt, newlength,false);
	 turt.turn_right(60);
	 triline(turt, newlength,true);
	 turt.turn_left(60);
	 triline(turt, newlength,false);
	 turt.turn_left(60);
	 triline(turt, newlength,true);
	 
	
   }
   else{
	 triline(turt, newlength, false);
	 turt.turn_right(60);
	 triline(turt, newlength, true);
	 turt.turn_right(60);
	 triline(turt, newlength, false);
	 turt.turn_left(60);
	 triline(turt, newlength, true);
	 turt.turn_left(60);
	 triline(turt, newlength, false);
	 turt.turn_left(60);
	 triline(turt, newlength, true);
	 turt.turn_left(60);
	 triline(turt, newlength, false);
	 turt.turn_right(60);
	 triline(turt, newlength, true);
	 turt.turn_right(60);
	 triline(turt, newlength, false);
}
	
}