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.
I'm sampling 1000 out of my point cloud and perform SVD:
Matrix pointsMatrix = new Matrix(nThPoints); SingularValueDecomposition svd = new SingularValueDecomposition(pointsMatrix);
I'm extracting the 3 PCA vectors from the result and adding their negatives:
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);
I'm magnifying each vector according to the data dimensions (going through each of the 1000 points and checking what is the biggest projection):
vector1 = Vec.projectData(vector1, nThPoints);
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);
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.
How can I do that?