code: public void generateGrid() {
          minx = minx - extendGrid;
          maxx = maxx + extendGrid;
          miny = miny - extendGrid;
          maxy = maxy + extendGrid;
          minz = minz - extendGrid;
          maxz = maxz + extendGrid;
  
          dim[0] = (int) Math.round(Math.abs(maxx - minx) / latticeConstant);
          dim[1] = (int) Math.round(Math.abs(maxy - miny) / latticeConstant);
          dim[2] = (int) Math.round(Math.abs(maxz - minz) / latticeConstant);
  
          grid = new double[dim[0] + 1][dim[1] + 1][dim[2] + 1];
      }
docs: Main method creates a grid between given boundaries (dimensions).
  The grid my be extended over the given boundaries with the
  variable extendGrid.