jme.math
Class Matrix

java.lang.Object
  extended byjme.math.Matrix

public class Matrix
extends java.lang.Object

Matrix defines and maintains a 4x4 matrix. This matrix is intended for use in a translation and rotational capacity. It provides convinience methods for creating the matrix from a multitude of sources.

Version:
$Id: Matrix.java,v 1.6 2003/09/04 21:17:51 mojomonkey Exp $
Author:
Mark Powell

Field Summary
 float[][] matrix
           
 
Constructor Summary
Matrix()
          Constructor instantiates a new Matrix that is set to the identity matrix.
Matrix(Matrix mat)
          Constructor instantiates a new Matrix that is set to the provided matrix.
 
Method Summary
 void add(Matrix matrix)
          add adds the values of a parameter matrix to this matrix.
 void angleRotationDegrees(Vector angles)
           
 void angleRotationRadians(Vector angles)
           
 void copy(Matrix matrix)
           
 float[][] getMatrix()
          getMatrix returns the current matrix as an array of floats.
 void inverseRotateVect(float[] vector)
          inverseRotateVect rotates a given vector by the rotation part of this matrix.
 void inverseTranslateVect(float[] vector)
          inverseTranslateVect translates a given vector by the translation part of this matrix.
 void loadIdentity()
          loadIdentity sets this matrix to the identity matrix, namely all zeros with ones along the diagonal.
 void multiply(float scalar)
          multiply multiplies this matrix by a scalar.
 Matrix multiply(Matrix in2)
          multiply multiplies this matrix with another matrix.
 void set(float[] matrix)
           
 void set(float[][] matrix)
          set sets the values of this matrix from an array of values.
 void set(Quaternion quaternion)
           
 void setInverseRotationDegrees(float[] angles)
          setInverseRotationDegrees builds an inverted rotation from Euler angles that are in degrees.
 void setInverseRotationRadians(float[] angles)
          setInverseRotationRadians builds an inverted rotation from Euler angles that are in radians.
 void setInverseTranslation(float[] translation)
          setInverseTranslation will set the matrix's inverse translation values.
 void setRotationQuaternion(Quaternion quat)
          setRotationQuaternion builds a rotation from a Quaternion.
 void setTranslation(float[] translation)
          setTranslation will set the matrix's translation values.
 void tensorProduct(Vector u, Vector v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matrix

public float[][] matrix
Constructor Detail

Matrix

public Matrix()
Constructor instantiates a new Matrix that is set to the identity matrix.


Matrix

public Matrix(Matrix mat)
Constructor instantiates a new Matrix that is set to the provided matrix. This constructor copies a given Matrix. If the provided matrix is null, the constructor sets the matrix to the identity.

Parameters:
mat - the matrix to copy.
Method Detail

loadIdentity

public void loadIdentity()
loadIdentity sets this matrix to the identity matrix, namely all zeros with ones along the diagonal.


set

public void set(float[][] matrix)
set sets the values of this matrix from an array of values.

Parameters:
matrix - the matrix to set the value to.
Throws:
MonkeyRuntimeException - if the array is not of size 16.

set

public void set(float[] matrix)

set

public void set(Quaternion quaternion)

copy

public void copy(Matrix matrix)

add

public void add(Matrix matrix)
add adds the values of a parameter matrix to this matrix.

Parameters:
matrix - the matrix to add to this.

multiply

public void multiply(float scalar)
multiply multiplies this matrix by a scalar.

Parameters:
scalar - the scalar to multiply this matrix by.

multiply

public Matrix multiply(Matrix in2)
multiply multiplies this matrix with another matrix. The result matrix will then be returned. This matrix will be on the left hand side, while the parameter matrix will be on the right.

Parameters:
in2 - the matrix to multiply this matrix by.
Returns:
the resultant matrix
Throws:
MonkeyRuntimeException - if matrix is null.

setTranslation

public void setTranslation(float[] translation)
setTranslation will set the matrix's translation values.

Parameters:
translation - the new values for the translation.
Throws:
MonkeyRuntimeException - if translation is not size 3.

setInverseTranslation

public void setInverseTranslation(float[] translation)
setInverseTranslation will set the matrix's inverse translation values.

Parameters:
translation - the new values for the inverse translation.
Throws:
MonkeyRuntimeException - if translation is not size 3.

angleRotationRadians

public void angleRotationRadians(Vector angles)

angleRotationDegrees

public void angleRotationDegrees(Vector angles)

setRotationQuaternion

public void setRotationQuaternion(Quaternion quat)
setRotationQuaternion builds a rotation from a Quaternion.

Parameters:
quat - the quaternion to build the rotation from.
Throws:
MonkeyRuntimeException - if quat is null.

setInverseRotationRadians

public void setInverseRotationRadians(float[] angles)
setInverseRotationRadians builds an inverted rotation from Euler angles that are in radians.

Parameters:
angles - the Euler angles in radians.
Throws:
MonkeyRuntimeException - if angles is not size 3.

setInverseRotationDegrees

public void setInverseRotationDegrees(float[] angles)
setInverseRotationDegrees builds an inverted rotation from Euler angles that are in degrees.

Parameters:
angles - the Euler angles in degrees.
Throws:
MonkeyRuntimeException - if angles is not size 3.

getMatrix

public float[][] getMatrix()
getMatrix returns the current matrix as an array of floats. Size 16.

Returns:
the array of floats that represent this matrix.

inverseTranslateVect

public void inverseTranslateVect(float[] vector)
inverseTranslateVect translates a given vector by the translation part of this matrix.

Parameters:
vector - the vector to be translated.
Throws:
MonkeyRuntimeException - if the size of the vector is not 3.

inverseRotateVect

public void inverseRotateVect(float[] vector)
inverseRotateVect rotates a given vector by the rotation part of this matrix.

Parameters:
vector - the vector to be rotated.
Throws:
MonkeyRuntimeException - if the size of the vector is not 3.

tensorProduct

public void tensorProduct(Vector u,
                          Vector v)