// ConvHull.POV // version 1.0 // // a test file for 'ConvHull.inc' // // by Michael Andrews, Feb 2003 // // +w400 +h400 +a0.2 +kff5 #include "rand.inc" #include "subrandom.inc" #include "convhull.inc" global_settings {assumed_gamma 1} camera { location <3,4,-5> look_at <0,0,0> right x up y angle 20 } plane { y,-1 pigment { checker color rgb <1,0.7,0.4>*0.3, color rgb <0.7,1,0.4>*0.2 scale .2 } } light_source { <10,10,-10> .7 } light_source { <-10,10,-10> .6 } // ---------------------------------------- #declare Col = spline { linear_spline 0 , <0,0,0>, 1/7, <0,0,1>, 2/7, <1,0,1>, 3/7, <1,0,0>, 4/7, <1,1,0>, 5/7, <1,1,1>, 6/7, <0,1,1>, 1 , <0,1,0> } #switch (frame_number) #case (1) #case (2) #case (3) #declare Nb=200; #declare P = array [Nb] Sub_Random_Dist(P, frame_number-1, 2, 0) #break #case (4) #declare Nb=400; #declare P = array [Nb] #declare S = seed(74); #declare C = 0; #while (C < Nb) #declare P[C] = VRand_In_Sphere(S); #declare C = C + 1; #end #break #else #declare Nb=400; #declare P = array [Nb] #declare S = seed(74); #declare C = 0; #while (C < Nb) #declare P[C] = VRand_In_Box(-0.7,0.7,S); #declare C = C + 1; #end #end // Create convex hull of points using 'beneath-beyond' algorithm: #declare Pnt = array[1] #declare Edg = array[1][2] #declare Tri = array[1][3] Convex_Hull (P, Pnt, Edg, Tri) #declare nP = dimension_size(Pnt,1); #declare nE = dimension_size(Edg,1); #declare nT = dimension_size(Tri,1); #debug concat("Hull: ", str(nP,0,0), " points returned.\n") union { #declare C = 0; #while (C < nP) #ifdef (Pnt[C]) sphere { P[Pnt[C]], .025 #declare F = C/(nP-1); pigment { color rgb Col(F) } finish { ambient .3 diffuse .5 } no_shadow } #end #declare C = C + 1; #end } #debug concat("Hull: ", str(nE,0,0), " edges returned.\n") union { #declare C = 0; #while (C < nE) cylinder { P[Edg[C][0]], P[Edg[C][1]], 0.015 } #declare C = C + 1; #end pigment { rgb 0.5 } finish { ambient .3 diffuse .5 } no_shadow } #debug concat("Hull: ", str(nT,0,0), " triangles returned.\n") mesh { #declare C = 0; #while (C < nT) triangle { P[Tri[C][0]], P[Tri[C][1]], P[Tri[C][2]] } #declare C = C + 1; #end texture { pigment { rgbf <.9,.9,.7,.9> } } interior_texture { pigment { rgbf <.4,.4,.7,.7> } } interior { fade_distance 1 fade_power 1001 } }