#include "colors.inc" // math adapted from http://mathworld.wolfram.com/Spirograph.html // original code Stefan Viljoen // adapted by DLM camera { location <0,0,30> look_at <0,0,0> } light_source { <0,0,10> color White } // these vars describe the wheels #declare radius_fixed = 5; //fixed wheel #declare radius_rotating = 2; //rotating wheel #declare spiro_offset = 1; //pen offset on rotating wheel #declare theta = 0; //radians #declare theta_max = 8*pi; //upper limit for theta #declare rot = (2*pi)/180; // fraction of a revolution for each step (step size in rad) #declare cyl_rad = .5; #declare x_scale = 1; #declare y_scale = 1; //#declare z_fac = 0.0025; // initial pos #declare x_loc = x_scale * ( (radius_fixed + radius_rotating) * cos(theta) -(radius_rotating + spiro_offset) *cos((radius_fixed+radius_rotating)/radius_rotating*theta)); #declare y_loc = y_scale *( (radius_fixed + radius_rotating) * sin(theta) -(radius_rotating + spiro_offset) *sin((radius_fixed+radius_rotating)/radius_rotating*theta)); #declare z_loc = 0; #declare x_loc_o = 0; #declare y_loc_o = 0; #declare z_loc_o = 0; #while (theta < theta_max) #declare x_loc_o = x_loc; #declare y_loc_o = y_loc ; #declare theta = theta + rot; #declare x_loc = x_scale * ( (radius_fixed + radius_rotating) * cos(theta) -(radius_rotating + spiro_offset) *cos((radius_fixed+radius_rotating)/radius_rotating*theta)); #declare y_loc = y_scale *( (radius_fixed + radius_rotating) * sin(theta) -(radius_rotating + spiro_offset) *sin((radius_fixed+radius_rotating)/radius_rotating*theta)); // cylinder line segs /* cylinder { ,,cyl_rad material { texture { pigment { color rgb } } } } */ // sphere sweep sphere { ,cyl_rad material { texture { pigment { color rgb } } } } #end