com.jme.math
Class Matrix3f

java.lang.Object
  extended bycom.jme.math.Matrix3f

public class Matrix3f
extends java.lang.Object

Matrix3f defines a 3x3 matrix. Matrix data is maintained internally and is acessible via the get and set methods. Convenience methods are used for matrix operations as well as generating a matrix from a given set of values.

Version:
$Id: Matrix3f.java,v 1.32 2005/04/06 20:24:25 renanse Exp $
Author:
Mark Powell, Joshua Slack -- Optimization

Field Summary
 float m00
           
 float m01
           
 float m02
           
 float m10
           
 float m11
           
 float m12
           
 float m20
           
 float m21
           
 float m22
           
 
Constructor Summary
Matrix3f()
          Constructor instantiates a new Matrix3f object.
Matrix3f(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
          constructs a matrix with the given values.
Matrix3f(Matrix3f mat)
          Copy constructor that creates a new Matrix3f object that is the same as the provided matrix.
 
Method Summary
 void add(Matrix3f mat)
          add adds the values of a parameter matrix to this matrix.
 Matrix3f adjoint()
          Returns a new matrix representing the adjoint of this matrix.
 Matrix3f adjoint(Matrix3f store)
          Places the adjoint of this matrix in store (creates store if null.)
 void copy(Matrix3f matrix)
          copy transfers the contents of a given matrix to this matrix.
 float determinant()
          determinant generates the determinate of this matrix.
 java.nio.FloatBuffer fillFloatBuffer(java.nio.FloatBuffer fb)
          fillFloatBuffer fills a FloatBuffer object with the matrix data.
 void fromAngleAxis(float angle, Vector3f axis)
          fromAngleAxis sets this matrix4f to the values specified by an angle and an axis of rotation.
 void fromAngleNormalAxis(float angle, Vector3f axis)
          fromAngleNormalAxis sets this matrix4f to the values specified by an angle and a normalized axis of rotation.
 void fromAxes(Vector3f uAxis, Vector3f vAxis, Vector3f wAxis)
          Recreate Matrix using the provided axis.
 void fromAxisAngle(Vector3f axis, float radian)
          fromAxisAngle creates a rotational matrix given an axis and an angle.
 float get(int i, int j)
          get retrieves a value from the matrix at the given position.
 Vector3f getColumn(int i)
          getColumn returns one of three columns specified by the parameter.
 Vector3f getColumn(int i, Vector3f store)
          getColumn returns one of three columns specified by the parameter.
 Matrix3f invert()
          Inverts this matrix as a new Matrix3f.
 Matrix3f invert(Matrix3f store)
          Inverts this matrix and stores it in the given store.
 Matrix3f invertLocal()
          Inverts this matrix locally.
 void loadIdentity()
          loadIdentity sets this matrix to the identity matrix.
 Matrix3f mult(Matrix3f mat)
          mult multiplies this matrix by a given matrix.
 Matrix3f mult(Matrix3f mat, Matrix3f product)
          mult multiplies this matrix by a given matrix.
 Vector3f mult(Vector3f vec)
          mult multiplies this matrix by a given Vector3f object.
 Vector3f mult(Vector3f vec, Vector3f product)
          Multiplies this 3x3 matrix by the 1x3 Vector vec and stores the result in product.
 Matrix3f multLocal(float scale)
          multLocal multiplies this matrix internally by a given float scale factor.
 Matrix3f multLocal(Matrix3f mat)
          mult multiplies this matrix by a given matrix.
 Vector3f multLocal(Vector3f vec)
          multLocal multiplies this matrix by a given Vector3f object.
 void set(float[] matrix)
          set sets the values of this matrix from an array of values assuming that the data is rowMajor order;
 void set(float[][] matrix)
          set sets the values of the matrix to those supplied by the 3x3 two dimenion array.
 void set(float[] matrix, boolean rowMajor)
          set sets the values of this matrix from an array of values;
 void set(int i, int j, float value)
          set places a given value into the matrix at the given position.
 void set(Quaternion quaternion)
          set defines the values of the matrix based on a supplied Quaternion.
 void setColumn(int i, Vector3f column)
          setColumn sets a particular column of this matrix to that represented by the provided vector.
 java.nio.FloatBuffer toFloatBuffer()
          toFloatBuffer returns a FloatBuffer object that contains the matrix data.
 java.lang.String toString()
          toString returns the string representation of this object.
 Matrix3f transpose()
          transpose locally transposes this Matrix.
 Matrix3f transposeLocal()
          Transposes this matrix in place.
 Matrix3f zero()
          Sets all of the values in this matrix to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m00

public float m00

m01

public float m01

m02

public float m02

m10

public float m10

m11

public float m11

m12

public float m12

m20

public float m20

m21

public float m21

m22

public float m22
Constructor Detail

Matrix3f

public Matrix3f()
Constructor instantiates a new Matrix3f object. The initial values for the matrix is that of the identity matrix.


Matrix3f

public Matrix3f(float m00,
                float m01,
                float m02,
                float m10,
                float m11,
                float m12,
                float m20,
                float m21,
                float m22)
constructs a matrix with the given values.

Parameters:
m00 - 0x0 in the matrix.
m01 - 0x1 in the matrix.
m02 - 0x2 in the matrix.
m10 - 1x0 in the matrix.
m11 - 1x1 in the matrix.
m12 - 1x2 in the matrix.
m20 - 2x0 in the matrix.
m21 - 2x1 in the matrix.
m22 - 2x2 in the matrix.

Matrix3f

public Matrix3f(Matrix3f mat)
Copy constructor that creates a new Matrix3f object that is the same as the provided matrix.

Parameters:
mat - the matrix to copy.
Method Detail

copy

public void copy(Matrix3f matrix)
copy transfers the contents of a given matrix to this matrix. If a null matrix is supplied, this matrix is set to the identity matrix.

Parameters:
matrix - the matrix to copy.

get

public float get(int i,
                 int j)
get retrieves a value from the matrix at the given position. If the position is invalid a JmeException is thrown.

Parameters:
i - the row index.
j - the colum index.
Returns:
the value at (i, j).

getColumn

public Vector3f getColumn(int i)
getColumn returns one of three columns specified by the parameter. This column is returned as a Vector3f object.

Parameters:
i - the column to retrieve. Must be between 0 and 2.
Returns:
the column specified by the index.

getColumn

public Vector3f getColumn(int i,
                          Vector3f store)
getColumn returns one of three columns specified by the parameter. This column is returned as a Vector3f object.

Parameters:
i - the column to retrieve. Must be between 0 and 2.
store - the vector object to store the result in. if null, a new one is created.
Returns:
the column specified by the index.

toFloatBuffer

public java.nio.FloatBuffer toFloatBuffer()
toFloatBuffer returns a FloatBuffer object that contains the matrix data.

Returns:
matrix data as a FloatBuffer.

fillFloatBuffer

public java.nio.FloatBuffer fillFloatBuffer(java.nio.FloatBuffer fb)
fillFloatBuffer fills a FloatBuffer object with the matrix data.

Parameters:
fb - the buffer to fill, must be correct size
Returns:
matrix data as a FloatBuffer.

setColumn

public void setColumn(int i,
                      Vector3f column)
setColumn sets a particular column of this matrix to that represented by the provided vector.

Parameters:
i - the column to set.
column - the data to set.

set

public void set(int i,
                int j,
                float value)
set places a given value into the matrix at the given position. If the position is invalid a JmeException is thrown.

Parameters:
i - the row index.
j - the colum index.
value - the value for (i, j).

set

public void set(float[][] matrix)
set sets the values of the matrix to those supplied by the 3x3 two dimenion array.

Parameters:
matrix - the new values of the matrix.
Throws:
JmeException - if the array is not of size 9.

fromAxes

public void fromAxes(Vector3f uAxis,
                     Vector3f vAxis,
                     Vector3f wAxis)
Recreate Matrix using the provided axis.

Parameters:
uAxis - Vector3f
vAxis - Vector3f
wAxis - Vector3f

set

public void set(float[] matrix)
set sets the values of this matrix from an array of values assuming that the data is rowMajor order;

Parameters:
matrix - the matrix to set the value to.

set

public void set(float[] matrix,
                boolean rowMajor)
set sets the values of this matrix from an array of values;

Parameters:
matrix - the matrix to set the value to.
rowMajor - whether the incoming data is in row or column major order.

set

public void set(Quaternion quaternion)
set defines the values of the matrix based on a supplied Quaternion. It should be noted that all previous values will be overridden.

Parameters:
quaternion - the quaternion to create a rotational matrix from.

loadIdentity

public void loadIdentity()
loadIdentity sets this matrix to the identity matrix. Where all values are zero except those along the diagonal which are one.


fromAngleAxis

public void fromAngleAxis(float angle,
                          Vector3f axis)
fromAngleAxis sets this matrix4f to the values specified by an angle and an axis of rotation. This method creates an object, so use fromAngleNormalAxis if your axis is already normalized.

Parameters:
angle - the angle to rotate (in radians).
axis - the axis of rotation.

fromAngleNormalAxis

public void fromAngleNormalAxis(float angle,
                                Vector3f axis)
fromAngleNormalAxis sets this matrix4f to the values specified by an angle and a normalized axis of rotation.

Parameters:
angle - the angle to rotate (in radians).
axis - the axis of rotation (already normalized).

mult

public Matrix3f mult(Matrix3f mat)
mult multiplies this matrix by a given matrix. The result matrix is returned as a new object. If the given matrix is null, a null matrix is returned.

Parameters:
mat - the matrix to multiply this matrix by.
Returns:
the result matrix.

mult

public Matrix3f mult(Matrix3f mat,
                     Matrix3f product)
mult multiplies this matrix by a given matrix. The result matrix is returned as a new object. If the given matrix is null, a null matrix is returned.

Parameters:
mat - the matrix to multiply this matrix by.
product - the matrix to store the result in. if null, a new matrix3f is created.
Returns:
a matrix3f object containing the result of this operation

mult

public Vector3f mult(Vector3f vec)
mult multiplies this matrix by a given Vector3f object. The result vector is returned. If the given vector is null, null will be returned.

Parameters:
vec - the vector to multiply this matrix by.
Returns:
the result vector.

mult

public Vector3f mult(Vector3f vec,
                     Vector3f product)
Multiplies this 3x3 matrix by the 1x3 Vector vec and stores the result in product.

Parameters:
vec - The Vector3f to multiply.
product - The Vector3f to store the result.
Returns:
The given product vector.

multLocal

public Matrix3f multLocal(float scale)
multLocal multiplies this matrix internally by a given float scale factor.

Parameters:
scale - the value to scale by.
Returns:
this Matrix3f

multLocal

public Vector3f multLocal(Vector3f vec)
multLocal multiplies this matrix by a given Vector3f object. The result vector is stored inside the passed vector, then returned . If the given vector is null, null will be returned.

Parameters:
vec - the vector to multiply this matrix by.
Returns:
The passed vector after multiplication

multLocal

public Matrix3f multLocal(Matrix3f mat)
mult multiplies this matrix by a given matrix. The result matrix is saved in the current matrix. If the given matrix is null, nothing happens. The current matrix is returned. This is equivalent to this*=mat

Parameters:
mat - the matrix to multiply this matrix by.
Returns:
This matrix, after the multiplication

transposeLocal

public Matrix3f transposeLocal()
Transposes this matrix in place. Returns this matrix for chaining

Returns:
This matrix after transpose

invert

public Matrix3f invert()
Inverts this matrix as a new Matrix3f.

Returns:
The new inverse matrix

invert

public Matrix3f invert(Matrix3f store)
Inverts this matrix and stores it in the given store.

Returns:
The store

invertLocal

public Matrix3f invertLocal()
Inverts this matrix locally.

Returns:
this

adjoint

public Matrix3f adjoint()
Returns a new matrix representing the adjoint of this matrix.

Returns:
The adjoint matrix

adjoint

public Matrix3f adjoint(Matrix3f store)
Places the adjoint of this matrix in store (creates store if null.)

Parameters:
store - The matrix to store the result in. If null, a new matrix is created.
Returns:
store

determinant

public float determinant()
determinant generates the determinate of this matrix.

Returns:
the determinate

zero

public Matrix3f zero()
Sets all of the values in this matrix to zero.

Returns:
this matrix

add

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

Parameters:
mat - the matrix to add to this.

transpose

public Matrix3f transpose()
transpose locally transposes this Matrix.

Returns:
this object for chaining.

fromAxisAngle

public void fromAxisAngle(Vector3f axis,
                          float radian)
fromAxisAngle creates a rotational matrix given an axis and an angle. The angle is expected to be in radians.

Parameters:
axis - the axis to rotate about.
radian - the angle to rotate.

toString

public java.lang.String toString()
toString returns the string representation of this object. It is in a format of a 3x3 matrix. For example, an identity matrix would be represented by the following string. com.jme.math.Matrix3f
[
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
]

Returns:
the string representation of this object.