title: Find Bounding Box of a 3d point cloud using PCA
body: <p>I'm trying to find a bounding box of a 3d point cloud using PCA.
  I'm using the JAMA "Java Matrix Package" in order to perform SVD.</p>
  
  <ol>
  <li><p>I'm sampling 1000 out of my point cloud and perform SVD:</p>
  
  <blockquote>
  <pre><code>Matrix pointsMatrix = new Matrix(nThPoints);
  SingularValueDecomposition svd = new SingularValueDecomposition(pointsMatrix);
  </code></pre>
  </blockquote></li>
  <li><p>I'm extracting the 3 PCA vectors from the result and adding their negatives:</p>
  
  <blockquote>
    <p>double[] vector1 = {svd.getU().get(0, 0), svd.getU().get(1, 0),
    svd.getU().get(2, 0)};                 double[] vector1N = Vec.Mult(vector1,
    -1);
                  double[] vector2 = {svd.getU().get(0, 1), svd.getU().get(1, 1), svd.getU().get(2, 1)};
                  double[] vector2N = Vec.Mult(vector2, -1);
                  double[] vector3 = {svd.getU().get(0, 2), svd.getU().get(1, 2), svd.getU().get(2, 2)};
                  double[] vector3N = Vec.Mult(vector3, -1);</p>
  </blockquote></li>
  <li><p>I'm magnifying each vector according to the data dimensions (going through each of the 1000 points and checking what is the biggest projection):</p>
  
  <p>vector1 = Vec.projectData(vector1, nThPoints);</p>
  
  <pre><code>    vector1N = Vec.projectData(vector1N, nThPoints);
      vector2 = Vec.projectData(vector2, nThPoints);
      vector2N = Vec.projectData(vector2N, nThPoints);
      vector3 = Vec.projectData(vector3, nThPoints);
      vector3N = Vec.projectData(vector3N, nThPoints);
  </code></pre></li>
  </ol>
  
  <p>Now, that I have 6 new vectors I need somehow to calculate the 8 corners (while remembering the sample center) and I just don't know how to do that.</p>
  
  <p>How can I do that?</p>