title: Sorting 3D Grid Points into 3D Grid Cells
body: <p>I'm kind of at a roadblock while trying to assign 3D grid points as vertices to Cells.
  The Cells should just contain 8 points as corner vertices.</p>
  <p>I have created the grid without any issues, but cant seem to figure out how to sort the points to their according cells.</p>
  <p>This sketch illustrates how the points are indexed:</p>
  <p><a href="https://i.stack.imgur.com/pekJ6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pekJ6.jpg" alt="enter image description here" /></a></p>
  <p>One cube with 8 corner points would correspond to a Cell (ex. Cell0 would include points 0,1,3,4,6,7,9,10 as corner points).</p>
  <p>The code should be something like this:</p>
  <pre><code>public class Cell
      {
          public int[] Index =new int[8];
      }
  
  public void makeCells()
      {
          numCells = (xSize - 1) * (zSize - 1) * (ySize - 1);
          Cells = new Cell[numCells];
  
          for ( int i = 0, j = 0; i &lt; numCells; i++)
          {
              Cells[i] = new Cell();
              for ( int k = 0; k &lt;8; k++, j ++)
              {
                  Cells[i].Index[k] = j;
              }
          }
      }
  </code></pre>
  <p>I can't seem to get how to increment the indices properly so that they coordinate with the correct points.
  Any form of help would be appreciated!</p>