Class AlgorithmQuadraticFit
0 = C[0] + C[1]*X + C[2]*Y + C[3]*Z + C[4]*X^2 + C[5]*Y^2
+ C[6]*Z^2 + C[7]*X*Y + C[8]*X*Z + C[9]*Y*Z
The coefficients are estimated using a least-squares algorithm. There is one degree of freedom in the coefficients. It is removed by requiring the vector C = (C[0],...,C[9]) to be unit length. The least-square problem is to minimize E(C) = C^t M C with M = (sum_i V_i)(sum_i V_i)^t and
V = (1, X, Y, Z, X^2, Y^2, Z^2, X*Y, X*Z, Y*Z)
Minimum value is the smallest eigenvalue of M and C is a corresponding unit length eigenvector.
The quadratic equation can be factored into P^T A P + B^T P + K = 0 where P = (X,Y,Z), K = C[0], B = (C[1],C[2],C[3]), and A is a 3x3 symmetric matrix with A00 = C[4], A11 = C[5], A22 = C[6], A01 = C[7]/2, A02 = C[8]/2, and A12 = C[9]/2. Matrix A = R^T D R where R is orthogonal and D is diagonal (using an eigendecomposition). Define V = R P = (v0,v1,v2), E = R B = (e0,e1,e2), D = diag(d0,d1,d2), and f = K to obtain
d0 v0^2 + d1 v1^2 + d2 v^2 + e0 v0 + e1 v1 + e2 v2 + f = 0
The characterization of the surface depends on the signs of the d_i. For the MRI brain segmentation, the signs d_i
are all positive, thereby producing an ellipsoid.
The quadratic equation can finally be factored into
(P-G)^T R^T D R (P-G) = L
where G is the center of the surface, R is the orientation matrix, D is a diagonal matrix, and L is a constant.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected float[]the coeffficients of the approximating quadratic equation.protected float[]DOCUMENT ME!protected floatDOCUMENT ME!protected WildMagic.LibFoundation.Mathematics.Vector3fThe center G, orientation R, diagonal matrix D, and constant L in the factorization (P-G)^T R^T D R (P-G) = L.protected WildMagic.LibFoundation.Mathematics.Matrix3fDOCUMENT ME! -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmQuadraticFit(Vector<WildMagic.LibFoundation.Mathematics.Vector3f> kPoints) Fit a set of 3D points with a quadric surface. -
Method Summary
Modifier and TypeMethodDescriptionfinal WildMagic.LibFoundation.Mathematics.Vector3fGet the center of the quadric surface.final floatgetCoefficient(int i) Get the coefficients of the quadratic equation that represents the approximating quadric surface.final floatGet the constant term for the factored quadratic equation.final floatgetDiagonal(int i) Get a diagonal entry for the quadric surface.final WildMagic.LibFoundation.Mathematics.Matrix3fGet the orientation of the quadric surface.
-
Field Details
-
m_afCoeff
protected float[] m_afCoeffthe coeffficients of the approximating quadratic equation. -
m_afDiagonal
protected float[] m_afDiagonalDOCUMENT ME! -
m_fConstant
protected float m_fConstantDOCUMENT ME! -
m_kCenter
protected WildMagic.LibFoundation.Mathematics.Vector3f m_kCenterThe center G, orientation R, diagonal matrix D, and constant L in the factorization (P-G)^T R^T D R (P-G) = L. -
m_kOrient
protected WildMagic.LibFoundation.Mathematics.Matrix3f m_kOrientDOCUMENT ME!
-
-
Constructor Details
-
AlgorithmQuadraticFit
Fit a set of 3D points with a quadric surface. The various representations of the surface can be accessed by member functions.- Parameters:
kPoints- a vector of points, each vector element is of type Point3f
-
-
Method Details
-
getCenter
public final WildMagic.LibFoundation.Mathematics.Vector3f getCenter()Get the center of the quadric surface. This is the vector G in the factorization (P-G)^T R^T D R (P-G) = L.- Returns:
- the center point
-
getCoefficient
public final float getCoefficient(int i) Get the coefficients of the quadratic equation that represents the approximating quadric surface.- Parameters:
i- the coefficient index (0 invalid input: '<'= i invalid input: '<' 10)- Returns:
- the value of the coefficient
-
getConstant
public final float getConstant()Get the constant term for the factored quadratic equation. This is the L term in (P-G)^T R^T D R (P-G) = L.- Returns:
- the constant term
-
getDiagonal
public final float getDiagonal(int i) Get a diagonal entry for the quadric surface. This is a diagonal term for the matrix D in the factorization A = R^T D R where A is the coefficient matrix for the quadratic term in the equation.- Parameters:
i- the index of the diagonal (0 invalid input: '<'= i invalid input: '<' 3)- Returns:
- the diagonal entry
-
getOrient
public final WildMagic.LibFoundation.Mathematics.Matrix3f getOrient()Get the orientation of the quadric surface. This is the matrix R in the factorization A = R^T D R where A is the coefficient matrix for the quadratic term in the equation.- Returns:
- the orientation matrix
-