org.atzberger.mango.atz3d
Class Atz_LinearAlgebra

java.lang.Object
  extended by org.atzberger.mango.atz3d.Atz_LinearAlgebra

public class Atz_LinearAlgebra
extends java.lang.Object

Linear algebra routines needed for many of the operations associated with the 3D rendering engine.

Author:
Paul J. Atzberger
See Also:
http://www.atzberger.org

Constructor Summary
Atz_LinearAlgebra()
           
 
Method Summary
static void genRotationMatrix(double[] vec_theta, double[] matrix_result)
          Create rotation matrix about a given axis.
static void matrixLeftMultPtsX(int m, int n, double[] matrix, double[] ptsX, double[] result)
          Multiply a collection of points (vectors) on the left by a given matrix.
static void matrixMatrixMult(int m1, int n1, double[] matrixA, int m2, int n2, double[] matrixB, double[] result)
          Multiply two matrices.
static void matrixTranspose(int m, int n, double[] matrix, double[] result)
          Transpose a given matrix represented using our array format.
static void matrixVecMult(int m, int n, double[] matrix, double[] vec, double[] result)
          Multiply a vector by a matrix on the left.
static void performRotation(double[] vec_theta, double[] vec_w, double[] vec_result)
          Performs rotation of a vector w about the axis vec_theta by the amount theta.
static double vecNorm(double[] vec)
          Compute the norm of a vector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Atz_LinearAlgebra

public Atz_LinearAlgebra()
Method Detail

matrixTranspose

public static void matrixTranspose(int m,
                                   int n,
                                   double[] matrix,
                                   double[] result)
Transpose a given matrix represented using our array format.

Parameters:
m -
n -
matrix -
result -

matrixLeftMultPtsX

public static void matrixLeftMultPtsX(int m,
                                      int n,
                                      double[] matrix,
                                      double[] ptsX,
                                      double[] result)
Multiply a collection of points (vectors) on the left by a given matrix.

Parameters:
m -
n -
matrix -
ptsX -
result -

matrixVecMult

public static void matrixVecMult(int m,
                                 int n,
                                 double[] matrix,
                                 double[] vec,
                                 double[] result)
Multiply a vector by a matrix on the left.

Parameters:
m -
n -
matrix -
vec -
result -

matrixMatrixMult

public static void matrixMatrixMult(int m1,
                                    int n1,
                                    double[] matrixA,
                                    int m2,
                                    int n2,
                                    double[] matrixB,
                                    double[] result)
Multiply two matrices.

Parameters:
m1 -
n1 -
matrixA -
m2 -
n2 -
matrixB -
result -

vecNorm

public static double vecNorm(double[] vec)
Compute the norm of a vector

Parameters:
vec -
Returns:
vector norm

performRotation

public static void performRotation(double[] vec_theta,
                                   double[] vec_w,
                                   double[] vec_result)
Performs rotation of a vector w about the axis vec_theta by the amount theta.

This is done by using a rotation matrix about the z-axis and performing a change of variable to the appropriate axis q = vec_theta/norm(vec_theta).

This can be done by observing that z can be mapped to any point p = -q by using reflection about the plane orthogonal to v = z - p which passes through the origin. The reflection corresponds to the Householder transformation H = I - 2*v*v^T, p = Hz. To obtain a rotation we need to make this unitary matrix orientation preserving (determinant positive), which can be done by reflecting through the origin to obtain G = -H. This gives Gz = q, where G is now a rotation matrix. Note that v = (z - p)/norm(z - p) = (z + q)/norm(z + q). In the case that (z - p) is nearly zero we have that G is approximately the identify I.

The rotation matrix is then given by M = G*R*G^T.

To compute the rotation we avoid construction of the matrix and instead compute the action of the above operators, which is more efficient.

Parameters:
vec_theta -
vec_w -
vec_result -

genRotationMatrix

public static void genRotationMatrix(double[] vec_theta,
                                     double[] matrix_result)
Create rotation matrix about a given axis. The norm of the axis vector is used to determine the angular displacement for the rotation.

Parameters:
vec_theta -
matrix_result -