#version 3.5; #include "colors.inc" #include "transforms.inc" global_settings { assumed_gamma 1.0 } camera { location <0.0, 0.0,-13.0> direction 1.5*z right x*image_width/image_height look_at <0.0, 0.0, 0.0> } light_source { <100,100,0> color rgb 1 rotate y*120 shadowless } // build a trefoil using a sphere_sweep object. we could probably get away // with less than 53 defining points but - hey - it works. sphere_sweep { cubic_spline 53, #declare i = 0; #while (i < 53) #declare tt = 2*pi * i / 50; #declare xx = 1*cos( 1*tt) + 2*cos(-2*tt); #declare yy = 1*sin( 3*tt); #declare zz = 1*sin( 1*tt) + 2*sin(-2*tt); 0.2 #declare i = i + 1; #end pigment { White } finish { phong 0.5 phong_size 40 reflection { 0.2 } } } // add a bunch of sliding tori along the trefoil. // // rendering with initial_frame = 0, final_frame = 14, // initial_clock = 0, final_clock = 1, cyclic_animation = on // seems to work for a nice 15 or 30 frame per second animation // // note: one could probably simplify this part by using the // Spline_Trans transform. I wanted to calculate the derivatives // (dx, dy and dz) for use in some variations on this theme. #declare torus_count = 10; #declare dt = clock * 2*pi / torus_count; #declare tt = 0; #while (tt < (2*pi)) #declare xx = 1*cos( 1*(tt+dt)) + 2*cos(-2*(tt+dt)); #declare yy = 1*sin( 3*(tt+dt)); #declare zz = 1*sin( 1*(tt+dt)) + 2*sin(-2*(tt+dt)); #declare dx = -1*sin( 1*(tt+dt)) + 4*sin(-2*(tt+dt)); #declare dy = 3*cos( 3*(tt+dt)); #declare dz = 1*cos( 1*(tt+dt)) - 4*cos(-2*(tt+dt)); #declare dm = sqrt(dx*dx+dy*dy+dz*dz); torus { 0.4 0.15 pigment { Red } finish { phong 0.5 phong_size 40 reflection { 0.2 } } Point_At_Trans() translate } #declare tt = tt + 2*pi / torus_count; #end