/*========================================================= Disposizione di oggetti lungo una superficie Metodi e Modelli Matematici Gian Marco Todesco, dicembre 2007 http://archinet.uniroma3.it/mate/metodi/2007 =========================================================*/ #include "colors.inc" #include "textures.inc" global_settings { assumed_gamma 1 } camera { location 0.3*<-5,6,-3> right x*image_width/image_height look_at <0,0.0,0> angle 50 rotate -40*y } light_source { <1,4,-2> color 1} light_source { <4,6,2> color 0.5} plane { y,-1 pigment {checker Black White scale 0.25}} #macro Rampa(U,U0,U1) #local T = 0; #if(U>U1) #local T = 1; #else #if(U>U0) #local T = (U-U0)/(U1-U0); #local T = (-2*T + 3)*T*T; #end #end T #end #macro Superficie(U,V) #local X = U*2-1; #local Z = V*2-1; #local R2 = pow(U-0.5,2)+pow(V-0.5,2); #local Y = 0.3*exp(-R2*10)*sin(1.5*U*2*pi)*sin(1.5*V*2*pi); #end #declare N = 81; #declare M = 81; #declare Vertici = array[N][M]; #declare Normali = array[N][M]; #declare DSDU = array[N][M]; #declare UV = array[N][M]; //calcolo le posizioni dei vertici della superficie della griglia #declare I = 0; #while (I; // coordinate curvilinee #declare J = J + 1; #end #declare I = I + 1; #end // Disegno mesh { #local I = 1; #while (I #end // // Definisco l'oggetto da incollare sulla superficie // #declare Piccoletto = union { #local R = 0.05; box {-R,R pigment {White}} union { torus {2*R,R*0.1 } cone {0,R*0.2,-4*R*x,0 } torus {0.5*R,R*0.05 translate -4*R*x } texture {Silver_Metal} } sphere {-4*R*x,0.5*R*0.8 texture {Copper_Metal}} } // // Disegno gli oggetti sulla superficie // union { #local T = 0; #local Q = Curva(0); #local OldP = Superficie(Q.x,Q.y); #local DT = 0.0001; #local T = T + DT; #while (T<1) #local Q = Curva(T); #local P = Superficie(Q.x,Q.y); #while(T<1 & vlength(P-OldP)<0.15) #local T = T + DT; #local Q = Curva(T); #local P = Superficie(Q.x,Q.y); #end #local OldP = P; #local H = 0.00001; #local DU = Superficie(U+H,V)-Superficie(U-H,V); #local DV = Superficie(U,V+H)-Superficie(U,V-H); #local Nrm = vnormalize(vcross(DU,DV)); #local R = 0.05; #local Q = Curva(T+H); #local P1 = Superficie(Q.x,Q.y); #local Tg = vnormalize(P1-P); #local E0 = Nrm; #local E1 = Tg; #local E2 = vcross(E0,E1); object { Piccoletto matrix < E0.x,E0.y,E0.z, E1.x,E1.y,E1.z, E2.x,E2.y,E2.z, P.x,P.y,P.z> } #local I = I + 1; #end pigment {White} }