Graphics Reference
In-Depth Information
for(i=0;i<3;i++) {
for(j=0;j<3;j++) {
if (i == j) continue;
off += a[i][j] * a[i][j];
}
}
/* off = sqrt(off); not needed for norm comparison */
// Stop when norm no longer decreasing
if(n>2&&off>=prevoff)
return;
prevoff = off;
}
}
3 matrix used here, instead of applying a general approach
such as the Jacobi method the eigenvalues could be directly computed from a simple
cubic equation. The eigenvectors could then easily be found through, for example,
Gaussian elimination. Such an approach is described in [Cromwell94]. Given the
previously defined functions, computing a sphere from the two most distant points
(according to spread) now looks like:
For the particular 3
×
void EigenSphere(Sphere &eigSphere, Point pt[], int numPts)
{
Matrix33 m, v;
// Compute the covariance matrix m
CovarianceMatrix(m, pt, numPts);
// Decompose it into eigenvectors (in v) and eigenvalues (in m)
Jacobi(m, v);
// Find the component with largest magnitude eigenvalue (largest spread)
Vector e;
int maxc = 0;
float maxf, maxe = Abs(m[0][0]);
if ((maxf = Abs(m[1][1])) > maxe) maxc = 1, maxe = maxf;
if ((maxf = Abs(m[2][2])) > maxe) maxc = 2, maxe = maxf;
e[0] = v[0][maxc];
e[1] = v[1][maxc];
e[2] = v[2][maxc];
// Find the most extreme points along direction 'e'
 
Search WWH ::




Custom Search