// HOSE / Agave '00.03 // By Tsutomu HIGO E-mail: nj2t-hg@asahi-net.or.jp #version 3.1; global_settings { max_trace_level 6 assumed_gamma 2.2 } camera { location <-20,-50,-50> angle 76 look_at <-2, -10, 0> } //***************** Beads arrange culculation ***************** #declare Rndm = seed(59); #declare Rdg=5; //radius of arranging sphere //initialize the coordinates of beads (X=Cp[I][0] Y=Cp[I][1]) // (X=Cpd[I][0] Y=Cpd[I][1] Z=Cpd[I][2]) #declare Imax=100; #declare Cd=array[Imax][3] #declare Cdp=array[Imax][3] #declare I=0; #while (I0.3) #declare Ad=0.5*rand(Rndm); #end //confuse the arrangement #if (Ae-Ap<0) #declare Ap=Ap-2*pi; #end #declare Bo=acos(1/Rdg/tan(pi-2*Ao)); #if (Ao>pi/4) #declare Rb=2*Bo/pi; #else #declare Rb=1; #end #if (Ae-Ap-As-Al-Ad>0) #declare I=0; #while (I0) #declare I=0; #while (Ipi/2-1/Rdg) #declare Jd=Jdl; #end #declare Jd=Jd+1; #end #declare I=0; #while (I0) #declare Ai=sqrt(Cd[I][0]*Cd[I][0]+Cd[I][1]*Cd[I][1])/2/Rdg; #declare Ri=sin(Ai)*cos(Ai)/Ai; #else #declare Ai=0; #declare Ri=1; #end //arranging beads and calculating the coordinates of the holes position #declare Cdp[I][0]=Ri*Cd[I][0]; #declare Cdp[I][1]=Ri*Cd[I][1]; #declare Cdp[I][2]=Rdg-2*Rdg*sin(Ai)*sin(Ai); #declare I=I+1; #end #declare I=0; #while (I0) #declare Li=sqrt(Cd[I][0]*Cd[I][0]+Cd[I][1]*Cd[I][1]); Acosc (Cd[I][0]/Li,-Cd[I][1],Cd[I][1]) #declare Cd[I][0]=Li/Rdg; #else #declare Cd[I][0]=0; #declare Cd[I][1]=0; #end #declare I=I+1; #end //***************** Mesh treatment ***************** //triangle of the surface #macro Trid (Ph,Pv) #declare Ph1=mod(Ph-1+Hmax,Hmax); triangle { } triangle { } #end //normal vector of the point #macro Vd (Ph,Pv) <(Cp[mod(Ph-1+Hmax,Hmax)][Pv][1]-Cp[Ph][Pv][1])*(Cp[Ph][Pv-1][2]-Cp[Ph][Pv][2])-(Cp[Ph][Pv-1][1]-Cp[Ph][Pv][1])*(Cp[mod(Ph-1+Hmax,Hmax)][Pv][2]-Cp[Ph][Pv][2]), (Cp[Ph][Pv-1][0]-Cp[Ph][Pv][0])*(Cp[mod(Ph-1+Hmax,Hmax)][Pv][2]-Cp[Ph][Pv][2])-(Cp[mod(Ph-1+Hmax,Hmax)][Pv][0]-Cp[Ph][Pv][0])*(Cp[Ph][Pv-1][2]-Cp[Ph][Pv][2]), (Cp[mod(Ph-1+Hmax,Hmax)][Pv][0]-Cp[Ph][Pv][0])*(Cp[Ph][Pv-1][1]-Cp[Ph][Pv][1])-(Cp[Ph][Pv-1][0]-Cp[Ph][Pv][0])*(Cp[mod(Ph-1+Hmax,Hmax)][Pv][1]-Cp[Ph][Pv][1])> #end //smooth_triangle of the surface #macro Trisd (Ph,Pv) #declare Green = texture { pigment { color rgb<0.7-0.7*Pv/Zmax, 0.7+0.3*Pv/Zmax, 0.3> } finish { reflection 0.5 ambient 0.3 phong 1 diffuse 1 brilliance 1 } normal { ripples 1 scale 0.03 frequency 15 } } #declare Ph1=mod(Ph-1+Hmax,Hmax); smooth_triangle { Vd(Ph,Pv) Vd(Ph1,Pv-1) Vd(Ph,Pv-1) texture { Green} } smooth_triangle { Vd(Ph1,Pv) Vd(Ph1,Pv-1) Vd (Ph,Pv) texture { Green} } #end #macro Trisdc (Ph,Pv) #declare Green = texture { pigment { color rgb<0.7, 0.7, 0.3> } finish { reflection 0.5 ambient 0.3 phong 1 diffuse 1 brilliance 1 } normal { ripples 1 scale 0.03 frequency 15 } } #declare Ph1=mod(Ph-1+Hmax,Hmax); smooth_triangle { Vd(Ph,Pv) Vd(Ph1,Pv-1) Vd(Ph,Pv-1) texture { Green } } smooth_triangle { Vd(Ph1,Pv) Vd(Ph1,Pv-1) Vd (Ph,Pv) texture { Green } } #end //***************** Hose coordinates ***************** #declare Rdgg=1; //radius of arranging hose //initialize the coordinates for mesh Cp(x,y,z,r) #declare Zmax=12; #declare Hmax=3; #declare Cp=array[Hmax][Zmax+2][4] #declare Cc=array[Zmax+2][3] #declare Z=0; #while (Z translate } #end union{ #declare I=0; #while (I color <1,1,1>} background { color rgb <0,0,0.2> }