// gridhex1.pov
// 2013 Aug 28

// hex grid in XZ plane, dimensions microns

#include "colors.inc"
#include "textures.inc"

#declare  spc = 3.0 ;
#declare  wid = 0.3 ;
#declare  thk = 0.5 ;
#declare  nmx = 1.0 ;
#declare  nmz = 2.0 ;

#declare  dx  = spc * 0.75 ;
#declare  dz  = spc * sqrt( 3.0 ) / 4.0 ;
#declare  hz  = dz   - wid/2.0       ;
#declare  hx0 = 0.50*spc - wid/sqrt(3.0) ;
#declare  hx1 = 0.25*spc - wid/sqrt(3.0) ;

#declare  x0 = 0.99*0.50*spc ;
#declare  x1 = 0.99*0.25*spc ;
#declare  z1 = 0.99*dz ;

light_source { < 1000, 6000, 1000> color rgb 1.0 }
# camera { angle 30.0  location <5,20,-7> look_at <0.5*dx,0,-0.1*dz> sky z  }

// hole cut from plane
#declare hexhole = prism{ conic_sweep linear_spline 1, 0, 7,
    < x0,0>, < x1,z1>, < -x1,z1>, < -x0,0>, < -x1, -z1>, < x1,-z1>, < x0,0>
    scale < 1, 4, 1 >
    translate < 0, -3.4, 0 >
}

difference {
  box { < -29, thk, -29 >, <29,-1,29 > }
  union { 
    #declare nx = -nmx ;
    #while(  nx <  nmx + 1 ) 
      #declare nz = -nmz ;
      #while(  nz <  nmz + 1 ) 
         object { hexhole translate < (2*nx+0)*dx , 0, (2*nz+0)*dz > }
         object { hexhole translate < (2*nx+1)*dx , 0, (2*nz+1)*dz > }
         #declare nz = nz + 1 ;
       #end
       #declare nx = nx + 1 ;
     #end
  } 
  pigment { White }
  // texture { Aluminum }
}
box { < -29, 0, -29 >, <29,-5,29 >   pigment { Gray10 } }


