#include "colors.inc" camera { location <4, 0, -10> look_at <4, 0, 0> } background{White} light_source { <10, 10, 5> color White} light_source { <0, 20, 0> color White} //********************** Turtle Position **************************** // These represent the position and angle of the turtle #declare cylinderWidth=.1; #declare locx = 0; #declare locy = 0; #declare myAngle = 0; //************************* Macros ********************************** // This is a macro that moves the turtle forward by a distance s. #macro kmove(s) #declare locx_new = locx + s*cos(radians(myAngle)); #declare locy_new = locy + s*sin(radians(myAngle)); cylinder { , , s*cylinderWidth} #declare locx = locx_new; #declare locy = locy_new; #end // This is a macro that is recursive for moving the turtle around. #macro koch(s, recursion_depth) #if (recursion_depth > 0) union { object { koch(s/3, recursion_depth-1) } object { #declare myAngle = myAngle + 60; koch(s/3, recursion_depth-1) } object { #declare myAngle = myAngle -120; koch(s/3, recursion_depth-1) } object { #declare myAngle = myAngle + 60; koch(s/3, recursion_depth-1) } } #else kmove(s); #end #end //************************* Parameters ********************************** // This sets the number of levels of recursion #declare myDepth = 0; // This is the distance along x that the turtle moves. #declare mySize = 8; //*********************** DRAW THE TURTLE!! ******************************* // This is the command for actually drawing the Turtle's path based in the // distance and levels of recursion. object{ koch(mySize,myDepth) pigment { color Blue } }