astex
Class Matrix

java.lang.Object
  extended by astex.Matrix

public class Matrix
extends java.lang.Object

A class for storing and manipulating a 4x4 matrix.


Field Summary
 double x00
          The elements of the matrix.
 double x01
          The elements of the matrix.
 double x02
          The elements of the matrix.
 double x03
          The elements of the matrix.
 double x10
           
 double x11
           
 double x12
           
 double x13
           
 double x20
           
 double x21
           
 double x22
           
 double x23
           
 double x30
           
 double x31
           
 double x32
           
 double x33
           
 
Constructor Summary
Matrix()
          Default constructor.
Matrix(Matrix in)
          Default constructor.
 
Method Summary
static void adjoint(Matrix in, Matrix out)
          adjoint( original_matrix, inverse_matrix ) calculate the adjoint of a 4x4 matrix Let a denote the minor determinant of matrix A obtained by ij deleting the ith row and jth column from A.
 void copy(Matrix m)
          Copy m into this matrix.
 boolean equals(Matrix m)
          Does this matrix equal another matrix.
 void fromQuaternion(double[] q)
          Generate rotation matrix from quaternion.
 void fromQuaternion(double q1, double q2, double q3, double q4)
          Generate rotation matrix from quaternion.
static Matrix interpolate(Matrix MS, Matrix MF, double frac)
          Interpolate a new matrix.
static void interpolate(Matrix MS, Matrix MF, double frac, Matrix MI)
          Interpolate a new matrix.
static void invert(Matrix in, Matrix out)
          invert( original_matrix, inverse_matrix ) calculate the inverse of a 4x4 matrix -1 A = ___1__ adjoint A det A
 boolean isIdentity()
          Does this matrix equal another matrix.
 boolean isIdentity(double tol)
           
 void pretranslate(double tx, double ty, double tz)
          Translate the transformation matrix the other way.
 void print()
          Print a default message with the matrix.
 void print(java.lang.String message)
          Print the matrix.
 java.lang.String returnScript()
           
 void rotateAroundVector(double x, double y, double z, double theta)
          Rotate around a line.
 void rotateAroundVector(Point3d p, double theta)
          Rotate around a line.
 void rotateXdegrees(double d)
          Rotate around x in degrees.
 void rotateYdegrees(double d)
          Rotate around y in degrees.
 void rotateZdegrees(double d)
          Rotate around Z in degrees.
 void scale(double s)
          Scale the transformation matrix.
 void scale(double sx, double sy, double sz)
          Apply non uniform scale.
 void set(int i, int j, double val)
           
 void set(Matrix m)
          Set matrix from another.
 void setIdentity()
          Set the matrix to the identity matrix.
static void slerp(double[] Q0, double[] Q1, double T, double[] Result)
          The famous quaternion slerp.
 void toQuaternion(double[] q)
          Convert a matrix to a quaternion.
 void transform(Matrix m)
          Transform by another matrix.
 void transform(Point3d p)
          Transform a point by the current matrix.
 void transformByInverse(Point3d p)
          Transform a point by the inverse matrix (assumes rotation matrix)
 void translate(double tx, double ty, double tz)
          Translate the transformation matrix.
 void transpose()
          Transpose the matrix.
 void zero()
          Set the matrix to the zero matrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x00

public double x00
The elements of the matrix.


x01

public double x01
The elements of the matrix.


x02

public double x02
The elements of the matrix.


x03

public double x03
The elements of the matrix.


x10

public double x10

x11

public double x11

x12

public double x12

x13

public double x13

x20

public double x20

x21

public double x21

x22

public double x22

x23

public double x23

x30

public double x30

x31

public double x31

x32

public double x32

x33

public double x33
Constructor Detail

Matrix

public Matrix()
Default constructor.


Matrix

public Matrix(Matrix in)
Default constructor.

Method Detail

setIdentity

public void setIdentity()
Set the matrix to the identity matrix.


zero

public void zero()
Set the matrix to the zero matrix.


set

public void set(Matrix m)
Set matrix from another.


set

public void set(int i,
                int j,
                double val)

scale

public void scale(double s)
Scale the transformation matrix.


scale

public void scale(double sx,
                  double sy,
                  double sz)
Apply non uniform scale.


translate

public void translate(double tx,
                      double ty,
                      double tz)
Translate the transformation matrix.


pretranslate

public void pretranslate(double tx,
                         double ty,
                         double tz)
Translate the transformation matrix the other way.


rotateXdegrees

public void rotateXdegrees(double d)
Rotate around x in degrees.


rotateYdegrees

public void rotateYdegrees(double d)
Rotate around y in degrees.


rotateZdegrees

public void rotateZdegrees(double d)
Rotate around Z in degrees.


transform

public void transform(Matrix m)
Transform by another matrix.


transform

public void transform(Point3d p)
Transform a point by the current matrix.


transformByInverse

public void transformByInverse(Point3d p)
Transform a point by the inverse matrix (assumes rotation matrix)


rotateAroundVector

public void rotateAroundVector(Point3d p,
                               double theta)
Rotate around a line.


rotateAroundVector

public void rotateAroundVector(double x,
                               double y,
                               double z,
                               double theta)
Rotate around a line.


print

public void print()
Print a default message with the matrix.


print

public void print(java.lang.String message)
Print the matrix.


returnScript

public java.lang.String returnScript()

equals

public boolean equals(Matrix m)
Does this matrix equal another matrix.


isIdentity

public boolean isIdentity()
Does this matrix equal another matrix.


isIdentity

public boolean isIdentity(double tol)

copy

public void copy(Matrix m)
Copy m into this matrix.


transpose

public void transpose()
Transpose the matrix.


invert

public static void invert(Matrix in,
                          Matrix out)
invert( original_matrix, inverse_matrix ) calculate the inverse of a 4x4 matrix -1 A = ___1__ adjoint A det A


adjoint

public static void adjoint(Matrix in,
                           Matrix out)
adjoint( original_matrix, inverse_matrix ) calculate the adjoint of a 4x4 matrix Let a denote the minor determinant of matrix A obtained by ij deleting the ith row and jth column from A. i+j Let b = (-1) a ij ji The matrix B = (b ) is the adjoint of A ij


interpolate

public static Matrix interpolate(Matrix MS,
                                 Matrix MF,
                                 double frac)
Interpolate a new matrix.


interpolate

public static void interpolate(Matrix MS,
                               Matrix MF,
                               double frac,
                               Matrix MI)
Interpolate a new matrix.


toQuaternion

public void toQuaternion(double[] q)
Convert a matrix to a quaternion.


fromQuaternion

public void fromQuaternion(double[] q)
Generate rotation matrix from quaternion.


fromQuaternion

public void fromQuaternion(double q1,
                           double q2,
                           double q3,
                           double q4)
Generate rotation matrix from quaternion. Used by the fitting routine


slerp

public static void slerp(double[] Q0,
                         double[] Q1,
                         double T,
                         double[] Result)
The famous quaternion slerp.