global_settings { assumed_gamma 1.0 ambient_light .4 } background{color rgb .00} #declare cscale=10; camera { location <0.0, 2.0, -5.0>*8*cscale look_at <0.0, 0.0, 0.0> right x*image_width/image_height angle 80/cscale } // create a regular point light source light_source { 0*x // light's position (translated below) color rgb <1,1,1> // light's color translate <-20, 40, -20> } #declare lclock=clock+0; #declare f=10; #declare sig=function(tt){2*sin(f*2*pi*tt)} #declare x_a=-1; #declare x_b=-5; #declare x_t=function(tt){x_a+(x_b-x_a)*.5*(1-cos(2*pi*tt))} #declare v_t=function(tt){(x_b-x_a)*pi*(sin(2*pi*tt))} #declare c = 3*abs(x_b-x_a)*pi; //speed of waves, set to 3* sources max speed //sets sig_out to be sig at point xx at time tt, emitted at tp 1-D wave please #macro sig_rec(xx,tt,tp,sig_out) #local told=tt; //told =first guess when g=xx-x_t(tp)-c*(tt-tp)=0 #local gold=xx-x_t(told)-c*(tt-told); #local tnew=tt-.1; //tnew =next guess when g=xx-x_t(tp)-c*(tt-tp)=0 #local gnew=xx-x_t(tnew)-c*(tt-tnew); #declare tp=tnew; #while (abs(tnew-told)>.001) #declare tp=tnew-gnew*(tnew-told)/(gnew-gold); #local told=tnew; #local gold=gnew; #local tnew=tp; #local gnew=xx-x_t(tnew)-c*(tt-tnew); #end #declare sig_out=sig(tp); #end cylinder{-.2*y,.2*y,.401 pigment{color rgb <1,1,1>} finish{ambient 1.1 diffuse .6} translate x_t(lclock)*x } #if(abs(sig(lclock))>=.3) cylinder{-.0*y,sig(lclock)*y,.1 pigment{color rgb <1,1,1>} finish{ambient 1.1 diffuse .6} translate x_t(lclock)*x } sphere{sig(lclock)*y,.2 pigment{color rgb <1,1,1>} finish{ambient 1.1 diffuse .6} translate x_t(lclock)*x } #end cylinder{-.2*y,.2*y,.4 pigment{color rgbt <.5,.5,.5,.75>} finish{ambient .8 diffuse .6} translate x_t(0)*x } #declare xplot=x_t(lclock); #declare dx=.05; #declare tsig=0; #declare te=0; sig_rec(xplot,lclock,te,tsig); #declare first=; #while (xplot<32) #declare xplot=xplot+dx; #declare tsig=0; #declare te=0; sig_rec(xplot,lclock,te,tsig); #declare next=; cylinder{first, next,.08 pigment{color rgb <.5*(1-v_t(te))/c,.0,.5*(1+v_t(te))/c>} finish{ambient 12} } #declare first=next; #end #declare nf=10; #declare twf=(int(lclock*f-.05)-nf)/f;//first emitted pulse that is still visible #while (twf+<0,0,0,.7+.3*(lclock-twf)/(10/f)>} pigment{color rgbt <1,1,1>*.2+<0,0,0,.7+.3*(lclock-twf)/(10/f)>} finish{ambient 10 diffuse .0} no_shadow no_reflection translate x_t(twf)*x } #declare twf=twf+1/f; #end