// Last edited on 2013-01-19 04:16:01 by stolfilocal #macro flow_pathline(VX,VY,W,D,S, x0,y0, tt, ro,tx0, dp,rp,txp, coin,Rf) // Generates a pathline in the official steady-state flow velocity field // with parameters {VX,VY,W,D,S}, for the particle that is at // {x0,y0} when {t=0}. // // Shows that particle and a few others along the pathline, where they // will be at time {tt} // // // The flow velocity field is assumed to be given by // macro {flow_velocity(VX,VY,W,D,S,T, RM, xp,yp)} // // A highlighting circle is drawn around the origin. // // {x0,y0} Start point on patlhine. // // {ro} Radius of pathline. // {txo} Texture of pathline. // {dp} Desired distance between particles in pathline. // {rp} Radius of particle. // {txp} Texture of particle. // {Rc} Major radius of highlighting circle. // {rc} Minor radius of highlighting circle. // {txc} Texture of highlighting circle. // {coin} A randomness generator. // {Rf} Assume visible scene lies in {[-Rf _ +Rf]} in each axis. // {tt} Time of frame (0 start of movie, 1 end of movie). #local yo = -i*do; // Ordinate where pathline crosses Y axis. #local po = < 0, yo, 0 >; // Point where pathline crosses Y axis. union{ // Draw the highlightng circle: torus{ Rc,rc rotate 90*x texture{ txc } } // Draw the pathline and compute the particle linear speed {vox,voy} at X=0: #if (crv = 0) #local vox = B + C*yo; #local voy = D*vox; #local tf = Rf/vox; #local df = 1.1 * tf * < vox, voy, 0 >; cylinder{ po + df, po - df, ro texture { txo } } #else #local R = 1/crv; // May be infinite #local Ro = R - yo; // Radius of pathline; may be infinite. #local vox = A/Ro + B + C*yo; #local voy = 0; torus{ Ro,ro rotate 90*x translate R*y texture{ txo } } #end // Compute the linear particle speed when crossing the Y axis: #local vo = sqrt(vox*vox + voy*voy); // Adjust the spacing {dp} between particles in pathline. // An integer number {mp} of particles must cross the Y axis // when the clock ranges from 0 to 1 #local mp = max(1,int(vo/dp + 0.5)); #local dp_adj = vo/mp; #debug "\n" #debug concat("pathline ", str(i,1,0), "\n") #debug concat("ordinate yo = ", str(yo,6,4), "\n") #if (crv != 0) #debug concat("radius Ro = ", str(Ro,6,4), "\n") #end #debug concat("velocity vo = ", str(vo,6,4), "\n") #debug concat("spacing dp = ", str(dp_adj,8,6), "\n") #debug "\n" // Estimate max number {np} of particles to plot in each half of the figure: #local np = int(4*Rf/dp + 2); #local dk = 0.5*mod(i,2); // Relative shift of particles on pathline. #local fk = 0.2*(rand(coin) - 0.5); // Random particle shift. #if (i != 0) #local dk = dk + fk; #end // Draw the particles: #local ptic = sphere{ <0,0,0>,rp texture{ txp } } #local k = -np; #while (k <= +np) #local sp = (k + dk)*dp_adj + (tt-0.5)*vo; // Position of particle along pathline. #if (crv = 0) object{ ptic translate < 0, yo, 0> + sp*< vox/vo, voy/vo, 0 > } #else #local tp = degrees(sp/Ro); // Angular position in degrees CCW from Y axis #if (abs(tp) <= 180) object{ ptic translate -Ro*y rotate tp*z translate +R*y } #end #end #local k = k + 1; #end } #end