// bounding for catmul-rom spline // by its calculated Bezier control points global_settings { assumed_gamma 1 } camera {location <0,0.5,-1>*0.8 look_at 0} #default {finish {ambient .5 diffuse 0.6}} background{rgb 1} light_source{ <-4.470,4.533,4.883> rgb 1 } light_source{ <4.470,4.533,-4.883> rgb 1 } #declare N = 5; // Number of spline segments #declare crPoint = array[N+3] // Spline starts from crPoint[1] and ends at crPoint[N+1] // crPoint[0] and crPoint[N+2] are not on curve #declare R = array[N+3] #declare crPoly=array[N][4]; // Polynomial coefficients for every N segment #declare bPoly=array[N][4]; // Bezier control points for corresponding segments #declare Bound=array[N][2]; // Bound boxes #declare s = seed(1117); #local i = 0; #while (i; #declare R[i] = (i/2+rand(s))/100; #local i=i+1; #end #declare Sweep=sphere_sweep { cubic_spline N+3 #local i = 0; #while (i} } // Calculate Catmull-Rom segment coefficients: #local i=1; #while(ixMax) #local xMax=bPoly[i][j].x; #end #if(bPoly[i][j].y>yMax) #local yMax=bPoly[i][j].y; #end #if(bPoly[i][j].z>zMax) #local zMax=bPoly[i][j].z; #end #local j=j+1; #end #local rShift=max(R[i],R[i+1],R[i+2])*1.001;; #declare Bound[i][0]=-rShift; #declare Bound[i][1]=+rShift; #local i=i+1; #end #declare BoundObject=union{ #local i=0; #while(i} } #local i=i+1; #end } #declare Object = union{ object{Sweep} object{BoundObject} } #if(1) #declare Object=#object{Object #local vv=-(max_extent(Object)-min_extent(Object))/2; translate vv-min_extent(Object) scale 0.5/vlength(vv) //rotate -x*90 rotate y*-45 // rotate z*-90 } #end #object{Object}