Graphics Reference
In-Depth Information
c += pt[i];
c *= oon;
// Compute covariance elements
e00 = e11 = e22 = e01 = e02 = e12 = 0.0f;
for(inti=0;i<numPts; i++) {
// Translate points so center of mass is at origin
Point p = pt[i] - c;
// Compute covariance of translated points
e00 += p.x * p.x;
e11 += p.y * p.y;
e22 += p.z * p.z;
e01 += p.x * p.y;
e02 += p.x * p.z;
e12 += p.y * p.z;
}
// Fill in the covariance matrix elements
cov[0][0] = e00 * oon;
cov[1][1] = e11 * oon;
cov[2][2] = e22 * oon;
cov[0][1] = cov[1][0] = e01 * oon;
cov[0][2] = cov[2][0] = e02 * oon;
cov[1][2] = cov[2][1] = e12 * oon;
}
Once the covariance matrix has been computed, it can be decomposed in a manner
that reveals more about the principal directions of the variance. This decomposition is
performed by computing the eigenvalues and eigenvectors of the matrix. The relation-
ship between these is such that the eigenvector associated with the largest magnitude
eigenvalue corresponds to the axis along which the point data has the largest vari-
ance. Similarly, the eigenvector associated with the smallest magnitude eigenvalue is
the axis along which the data has the least variance. Robustly finding the eigenvalues
and eigenvectors of a matrix is a nontrivial task in general. Typically, they are found
using some (iterative) numerical technique (for which a good source is [Golub96]).
By definition, the covariance matrix is always symmetric. As a result, it decomposes
into real (rather than complex) eigenvalues and an orthonormal basis of eigenvec-
tors. For symmetric matrices, a simpler decomposition approach can be used. For
a moderate-size matrix, as here, the Jacobi method works quite well. The intricate
details of the Jacobi method are beyond the scope of this topic. Briefly, however,
the algorithm performs a number of transformation steps to the given input matrix.
Each step consists of applying a rotation to the matrix, bringing the matrix closer and
closer to a diagonal matrix (all elements zero, except along the diagonal). When the
matrix is diagonal, the elements on the diagonal are the eigenvalues. While this is
 
Search WWH ::




Custom Search