#version 3.7;
#include "rand.inc"

light_source{<1000,1000,-100> rgb 1}

camera {
  location  <7, 10, -10>
  angle 65
  look_at   <7, 0,  6> 
}
plane{y,0 pigment{checker rgb 0.1 rgb 0.2}}

#declare Seed = seed(7);

#declare minX =  1000;
#declare maxX = -1000;
#declare minZ =  1000;
#declare maxZ = -1000;
#declare maxY = -1000;

#declare N = 100;
#declare Varr0=array[100];
#declare Varr1=array[100];
#declare Varr2=array[100];

#for (I,0,99,1)
  #local X = Rand_Gauss(7,2,Seed);
  #local Z = Rand_Gauss(7,2,Seed);
  sphere{<X,0.1,Z>,0.1 pigment{rgb 1}}
  #if (X<minX)
    #declare minX = X;
  #end
  #if (X>maxX)
    #declare maxX = X;
  #end
  #if (Z<minZ)
    #declare minZ = Z;
  #end
  #if (Z>maxZ)
    #declare maxZ = Z;
  #end
  #local Y1 = Rand_Gauss(3,2,Seed);
  #local Y2 = Y1+Rand_Gauss(3,2,Seed);
  sphere{<X,Y1,Z>,0.1 pigment{rgb x}}
  sphere{<X,Y2,Z>,0.1 pigment{rgb y}}
  #if (Y2>maxY)
    #declare maxY = Y2;
  #end
  #declare Varr0[I]=<X,0.1,Z>;
  #declare Varr1[I]=<X,Y1,Z>;
  #declare Varr2[I]=<X,Y2,Z>;
#end

#debug concat("minX : ",str(minX,5,5)," ","maxX : ",str(maxX,5,5),"\n")
#debug concat("minZ : ",str(minZ,5,5)," ","maxZ : ",str(maxZ,5,5),"\n")
#debug concat("maxY : ",str(maxY,5,5),"\n")

/* 
// file that voro++ command line utility understands
#fopen Voro "vorodat.txt" write
#for (I,0,N-1,1)
  #write(Voro,I," ",Varr0[I].x," ",Varr0[I].y," ",Varr0[I].z,"\n")
#end
#for (I,0,N-1,1)
  #write(Voro,I+100," ",Varr1[I].x," ",Varr1[I].y," ",Varr1[I].z,"\n")
#end
#for (I,0,N-1,1)
  #write(Voro,I+200," ",Varr2[I].x," ",Varr2[I].y," ",Varr2[I].z,"\n")
#end
*/


// file that tess, voro for python understands
#fopen Voro "vorodat.py" write
#write (Voro, "limits=[(",minX-5,",-5,",minZ-5,"),(",maxX+5,",",maxY+5,",",maxZ+5,")]\n")
#write(Voro,"vorodata=[\n")
#for (I,0,N-1,1)
  #write(Voro,"[",Varr0[I].x,",",Varr0[I].y,",",Varr0[I].z,"],\n")
#end
#for (I,0,N-1,1)
  #write(Voro,"[",Varr1[I].x,",",Varr1[I].y,",",Varr1[I].z,"],\n")
#end
//#for (I,0,N-1,1)
//  #write(Voro,"[",Varr2[I].x,",",Varr2[I].y,",",Varr2[I].z,"],\n")
//#end
#write(Voro,"]\n")