Common
Class MatrixInversion

java.lang.Object
  extended by Common.MatrixInversion

public class MatrixInversion
extends java.lang.Object

This class is responsible for inverting a matrix for solving a linear equation Ax = b .
This is needed for finding the physical coordinates from screen coordinates (for example, in showing mouse coordinates on the viewer in real time).
Here we need to solve the following equation for X_physical
X_physical * Transformation_Matrix = X_screen
We know the screen coordinates (current mouse coordinates), but need the corresponding physical coodinates.
This is a singleton class.

Since:
1.0

Field Summary
private static double EPSILON
           
private  int[] mEqnOrder
          Because of partial pivoting, equations may be reordered.
private static MatrixInversion mInstance
          Single instance of this class.
private  float[] mLUDecomposedMatrix
          LU decomposition of matrix (4X4).
private  float[] mMultipliers
           
 
Constructor Summary
private MatrixInversion()
          Class constructor.
 
Method Summary
private  void BackSubstitutor(float[] A, float[] b)
           
private  void ForwardSubstitutor(float[] A, float[] b)
           
static MatrixInversion Instance()
          Get the singleton instance of the class.
private  boolean LUDecomposer(float[] A, float[] b)
           
private  void ReorderB(float[] b)
           
 boolean SolveEqn(float[] A, float[] b, boolean decomposed)
           
private  boolean Solver(float[] A, float[] b, boolean decomposed)
          Solve the equation Ax = b, putting the answer in b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mLUDecomposedMatrix

private float[] mLUDecomposedMatrix
LU decomposition of matrix (4X4).


mEqnOrder

private int[] mEqnOrder
Because of partial pivoting, equations may be reordered.


mMultipliers

private float[] mMultipliers

EPSILON

private static final double EPSILON
See Also:
Constant Field Values

mInstance

private static MatrixInversion mInstance
Single instance of this class.

Constructor Detail

MatrixInversion

private MatrixInversion()
Class constructor.

Method Detail

Instance

public static MatrixInversion Instance()
Get the singleton instance of the class.

Returns:
MatrixInversion instance
See Also:
mLUDecomposedMatrix

LUDecomposer

private boolean LUDecomposer(float[] A,
                             float[] b)

ReorderB

private void ReorderB(float[] b)

ForwardSubstitutor

private void ForwardSubstitutor(float[] A,
                                float[] b)

BackSubstitutor

private void BackSubstitutor(float[] A,
                             float[] b)

Solver

private boolean Solver(float[] A,
                       float[] b,
                       boolean decomposed)
Solve the equation Ax = b, putting the answer in b.

Parameters:
A - A 16 element (4X4) array containing coefficient matrix.
b - RHS (4 element array). the array can get reordered (the inversion process involves partial pivoting). The array is overwritten with the result.
decomposed - boolean flag: true if A has been LU decomposed by an earlier invocation to this function with this flag false. false if this matrix is being sumbitted for the first time.
Returns:
true if inversion went OK, false if singular (or near singular matrix encountered).

SolveEqn

public boolean SolveEqn(float[] A,
                        float[] b,
                        boolean decomposed)