com.tensegrity.generic.math
Class Matrix44D

java.lang.Object
  extended bycom.tensegrity.generic.math.Matrix44D

public final class Matrix44D
extends java.lang.Object

Matrix44D represents a 4x4 matrix suitable for - affine transformations in 3d - affine transformations in 2d needed for a spline

Version:
$Id: Matrix44D.java,v 1.14 2005/04/08 08:08:05 MichaelKegel Exp $
Author:
MichaelKegel, Stepan Rutz

Field Summary
protected  double[] matrix
          Actual matrix data as an array of doubles of length 16.
 
Constructor Summary
Matrix44D()
          Constructs a 4x4 matrix and initializes this transform.
Matrix44D(double value)
          Constructs a 4x4 matrix and initializes all fields of the matrix to the supplied value.
Matrix44D(double[] source)
          Constructs a 4x4 matrix and initializes all fields of the matrix with the corresponding valued from the supplied array of length 16.
Matrix44D(double v00, double v01, double v02, double v03, double v10, double v11, double v12, double v13, double v20, double v21, double v22, double v23)
          Constructs and sets the values of the matrix by means of only the 12 relevant parameters.
Matrix44D(double v00, double v01, double v02, double v03, double v10, double v11, double v12, double v13, double v20, double v21, double v22, double v23, double v30, double v31, double v32, double v33)
          Constructs and sets the values of the matrix by means of all 16 parameters.
Matrix44D(Matrix44D source)
          Constructs a 4x4 matrix and initializes all fields of the matrix with the corresponding values from another matrix.
 
Method Summary
 void adjoint()
          Builds the adjoint matrix of the 4x4 matrix.
 void clear()
          Sets all fields of this matrix to 0.0.
 double determinant()
          Computes the determinant of this matrix
 void divide(double divisor)
          Divides all cells of this matrix by the supplied value.
 void identity()
          Sets this matrix to the identity matrix: [ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ].
 void invert()
          Inverts a 4x4 matrix generically.
 boolean isInvertible()
          Checks if the determinant is considered zero and so the matrix is not invertible.
 void multiply(double factor)
          Multiplies all cells of this matrix with the supplied value.
 void multiply(Matrix44D multiplier)
          Performs a full matrix multiplication of the form: this = this * other.
 void set(double value)
          Sets all fields of the matrix to the supplied value.
 void set(double v00, double v01, double v02, double v03, double v10, double v11, double v12, double v13, double v20, double v21, double v22, double v23)
          Sets the values of the matrix from only the 9 relevant parameters.
 void set(double v00, double v01, double v02, double v03, double v10, double v11, double v12, double v13, double v20, double v21, double v22, double v23, double v30, double v31, double v32, double v33)
          Sets the values of the matrix by means of all 16 parameters.
 void set(Matrix44D source)
          Fills all fields of the matrix with the corresponding values from the matrix supplied as arugment.
 java.lang.String toString()
          Returns a string representation of this matrix.
 void transform(Vector4 in, Vector4 out)
          Transforms a vector4 with this matrix.
 void transpose()
          Tranposes this matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

matrix

protected final double[] matrix
Actual matrix data as an array of doubles of length 16.

Constructor Detail

Matrix44D

public Matrix44D()
Constructs a 4x4 matrix and initializes this transform.


Matrix44D

public Matrix44D(double value)
Constructs a 4x4 matrix and initializes all fields of the matrix to the supplied value.

Parameters:
value - the value each cell of the matrix is initialized to.

Matrix44D

public Matrix44D(Matrix44D source)
Constructs a 4x4 matrix and initializes all fields of the matrix with the corresponding values from another matrix.

Parameters:
source - the other matrix whose values are copied into this object.

Matrix44D

public Matrix44D(double[] source)
Constructs a 4x4 matrix and initializes all fields of the matrix with the corresponding valued from the supplied array of length 16.

Parameters:
source - the array of length 9 that holds the values to put into this object.

Matrix44D

public Matrix44D(double v00,
                 double v01,
                 double v02,
                 double v03,
                 double v10,
                 double v11,
                 double v12,
                 double v13,
                 double v20,
                 double v21,
                 double v22,
                 double v23,
                 double v30,
                 double v31,
                 double v32,
                 double v33)
Constructs and sets the values of the matrix by means of all 16 parameters.

Parameters:
v00 - value for row 0, column 0
v01 - value for row 0, column 1
v02 - value for row 0, column 2
v03 - value for row 0, column 3
v10 - value for row 1, column 0
v11 - value for row 1, column 1
v12 - value for row 1, column 2
v13 - value for row 1, column 3
v20 - value for row 2, column 0
v21 - value for row 2, column 1
v22 - value for row 2, column 2
v23 - value for row 2, column 3
v30 - value for row 3, column 0
v31 - value for row 3, column 1
v32 - value for row 3, column 2
v33 - value for row 3, column 3

Matrix44D

public Matrix44D(double v00,
                 double v01,
                 double v02,
                 double v03,
                 double v10,
                 double v11,
                 double v12,
                 double v13,
                 double v20,
                 double v21,
                 double v22,
                 double v23)
Constructs and sets the values of the matrix by means of only the 12 relevant parameters. The bottom row is kept from the identity matrix.

Parameters:
v00 - value for row 0, column 0
v01 - value for row 0, column 1
v02 - value for row 0, column 2
v03 - value for row 0, column 3
v10 - value for row 1, column 0
v11 - value for row 1, column 1
v12 - value for row 1, column 2
v13 - value for row 1, column 3
v20 - value for row 2, column 0
v21 - value for row 2, column 1
v22 - value for row 2, column 2
v23 - value for row 2, column 3
Method Detail

set

public final void set(double value)
Sets all fields of the matrix to the supplied value.

Parameters:
value - the value each cell of the matrix is filled with.

set

public final void set(double v00,
                      double v01,
                      double v02,
                      double v03,
                      double v10,
                      double v11,
                      double v12,
                      double v13,
                      double v20,
                      double v21,
                      double v22,
                      double v23,
                      double v30,
                      double v31,
                      double v32,
                      double v33)
Sets the values of the matrix by means of all 16 parameters.

Parameters:
v00 - value for row 0, column 0
v01 - value for row 0, column 1
v02 - value for row 0, column 2
v03 - value for row 0, column 3
v10 - value for row 1, column 0
v11 - value for row 1, column 1
v12 - value for row 1, column 2
v13 - value for row 1, column 3
v20 - value for row 2, column 0
v21 - value for row 2, column 1
v22 - value for row 2, column 2
v23 - value for row 2, column 3
v30 - value for row 3, column 0
v31 - value for row 3, column 1
v32 - value for row 3, column 2
v33 - value for row 3, column 3

set

public final void set(double v00,
                      double v01,
                      double v02,
                      double v03,
                      double v10,
                      double v11,
                      double v12,
                      double v13,
                      double v20,
                      double v21,
                      double v22,
                      double v23)
Sets the values of the matrix from only the 9 relevant parameters. The last row of the matrix is set to the identity matrix values.

Parameters:
v00 - value for row 0, column 0
v01 - value for row 0, column 1
v02 - value for row 0, column 2
v03 - value for row 0, column 3
v10 - value for row 1, column 0
v11 - value for row 1, column 1
v12 - value for row 1, column 2
v13 - value for row 1, column 3
v20 - value for row 2, column 0
v21 - value for row 2, column 1
v22 - value for row 2, column 2
v23 - value for row 2, column 3

set

public final void set(Matrix44D source)
Fills all fields of the matrix with the corresponding values from the matrix supplied as arugment.

Parameters:
source - the matrix whose cells are copied into this one.

multiply

public final void multiply(double factor)
Multiplies all cells of this matrix with the supplied value.

Parameters:
factor - factor that all fields are multiplied with.

divide

public final void divide(double divisor)
Divides all cells of this matrix by the supplied value.

Parameters:
divisor - the divisor that all fields of this matrix are divided by.
Throws:
MathDynamicException - thrown if the divider is equal to zero.

multiply

public void multiply(Matrix44D multiplier)
Performs a full matrix multiplication of the form: this = this * other.

Parameters:
multiplier - a matrix that is multiplied onto this matrix.

clear

public final void clear()
Sets all fields of this matrix to 0.0.


identity

public final void identity()
Sets this matrix to the identity matrix: [ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ].


determinant

public final double determinant()
Computes the determinant of this matrix

Returns:
determinant of this matrix.

adjoint

public final void adjoint()
Builds the adjoint matrix of the 4x4 matrix. Needed for inverting matrices.


invert

public final void invert()
Inverts a 4x4 matrix generically. Works for every non-singular 4x4 matrix. Singular matrices don't have an inverse.
Notice: This function is rather expensive , so try to minimize its use.


transpose

public final void transpose()
Tranposes this matrix.


transform

public final void transform(Vector4 in,
                            Vector4 out)
Transforms a vector4 with this matrix.

Parameters:
in - the input vector.
out - the transformed output vector.

toString

public java.lang.String toString()
Returns a string representation of this matrix.

Returns:
a string representation of this matrix.

isInvertible

public boolean isInvertible()
Checks if the determinant is considered zero and so the matrix is not invertible.

Returns:
true, if the determinant is not considered zero


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.