title: Tessellate a plane of points
body: <p>I have a file filled with 3d points. The points form a plane. Here is an example file:</p>
  
  <pre><code>25
  1 -1 0
  1 -0.5 0
  1 0 0
  1 0.5 0
  1 1 0
  0.5 -1 0
  0.5 -0.5 0
  0.5 0 0
  0.5 0.5 0
  0.5 1 0
  0 -1 0
  0 -0.5 0
  0 0 0
  0 0.5 0
  0 1 0
  -0.5 -1 0
  -0.5 -0.5 0
  -0.5 0 0
  -0.5 0.5 0
  -0.5 1 0
  -1 -1 0
  -1 -0.5 0
  -1 0 0
  -1 0.5 0
  -1 1 0
  </code></pre>
  
  <p>Edit: Since my example set of points was too simple, here is a more complex example.</p>
  
  <pre><code>30
  -0.298858 -0.816497 1.11536
  0.0546949 -0.816497 0.761802
  0.408248 -0.816497 0.408248
  0.761802 -0.816497 0.0546949
  1.11536 -0.816497 -0.298858
  -0.462158 -0.489898 0.952056
  -0.108604 -0.489898 0.598502
  0.244949 -0.489898 0.244949
  0.598502 -0.489898 -0.108604
  0.952056 -0.489898 -0.462158
  -0.625457 -0.163299 0.788756
  -0.271904 -0.163299 0.435203
  0.0816497 -0.163299 0.0816497
  0.435203 -0.163299 -0.271904
  0.788756 -0.163299 -0.625457
  -0.788756 0.163299 0.625457
  -0.435203 0.163299 0.271904
  -0.0816497 0.163299 -0.0816497
  0.271904 0.163299 -0.435203
  0.625457 0.163299 -0.788756
  -0.952056 0.489898 0.462158
  -0.598502 0.489898 0.108604
  -0.244949 0.489898 -0.244949
  0.108604 0.489898 -0.598502
  0.462158 0.489898 -0.952056
  -1.11536 0.816497 0.298858
  -0.761802 0.816497 -0.0546949
  -0.408248 0.816497 -0.408248
  -0.0546949 0.816497 -0.761802
  0.298858 0.816497 -1.11536
  </code></pre>
  
  <p>These points are plotted like so:</p>
  
  <p><img src="https://i.stack.imgur.com/R5Xhv.png" alt="http://i.imgur.com/6zRrA.png"></p>
  
  <p>This file states that there are 25 points in the plane, and lists the points. The points are regularly spaced. Based on this information, how could I form triangles out of the point data and store it in a <code>std::vector&lt;Tri&gt;</code> where <code>Tri</code> is a</p>
  
  <pre><code>struct Tri 
  {
    double x1, y1, z1;
    double x2, y2, z2;
    double x3, y3, z3;
  };
  </code></pre>
  
  <p>Note also: Problem restrictions: External libraries are not allowed. The use of C++0X is not allowed (compiler: g++ 4.5.2).</p>