org.openmali.vecmath2
Class Matrix4f

java.lang.Object
  extended by org.openmali.vecmath2.MatrixMxNf
      extended by org.openmali.vecmath2.Matrix4f
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable

public class Matrix4f
extends MatrixMxNf
implements java.io.Externalizable

A single precision floating point 4 by 4 matrix. Inspired by Kenji Hiranabe's GMatrix implementation

See Also:
Serialized Form

Field Summary
static Matrix4f IDENTITY
           
protected static int M
           
protected static int N
           
static Matrix4f ROT_MINUS_90_DEG_BY_X_AXIS
           
static Matrix4f ROT_MINUS_90_DEG_BY_Y_AXIS
           
static Matrix4f ROT_MINUS_90_DEG_BY_Z_AXIS
           
static Matrix4f ROT_PLUS_90_DEG_BY_X_AXIS
           
static Matrix4f ROT_PLUS_90_DEG_BY_Y_AXIS
           
static Matrix4f ROT_PLUS_90_DEG_BY_Z_AXIS
           
static Matrix4f Z_UP_TO_Y_UP
           
static Matrix4f ZERO
           
 
Fields inherited from class org.openmali.vecmath2.MatrixMxNf
colSkip, dataBegin, isDirty, roTrick, values
 
Constructor Summary
  Matrix4f()
          Constructs and initializes a Matrix4f to all zeros.
protected Matrix4f(boolean readOnly)
          Constructs and initializes a Matrix4f to all zeros.
protected Matrix4f(boolean readOnly, float[] values)
          Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.
protected Matrix4f(boolean readOnly, float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
          Constructs and initializes a Matrix4f from the specified 16 values.
protected Matrix4f(boolean readOnly, int dataBegin, int colSkip, float[] values, boolean[] isDirty)
          Hidden constructor for #sharedSubMatrix3f(MatrixMxNf, int, int).
protected Matrix4f(boolean readOnly, Matrix3f mat)
          Constructs a new matrix with the same values as the Matrix3f parameter.
protected Matrix4f(boolean readOnly, Matrix4f mat)
          Constructs a new matrix with the same values as the Matrix4f parameter.
protected Matrix4f(boolean readOnly, Quaternion4f rot, Tuple3f pos, float scale)
          Constructs and initializes a Matrix4f from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.
protected Matrix4f(boolean readOnly, Tuple3f pos, Matrix3f rot, float scale)
          Constructs and initializes a Matrix4f from the rotation matrix, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.
  Matrix4f(float[] values)
          Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.
  Matrix4f(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
          Constructs and initializes a Matrix4f from the specified 16 values.
protected Matrix4f(int dataBegin, int colSkip, float[] values, boolean[] isDirty)
          Hidden constructor for #sharedSubMatrix3f(MatrixMxNf, int, int).
  Matrix4f(Matrix3f mat)
          Constructs a new matrix with the same values as the Matrix3f parameter.
  Matrix4f(Matrix4f mat)
          Constructs a new matrix with the same values as the Matrix4f parameter.
  Matrix4f(Quaternion4f rot, Tuple3f pos, float scale)
          Constructs and initializes a Matrix4f from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.
  Matrix4f(Tuple3f pos, Matrix3f rot, float scale)
          Constructs and initializes a Matrix4f from the rotation matrix, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.
 
Method Summary
 Matrix4f add(float scalar, Matrix4f mat)
          Adds a scalar to each component of the matrix m1 and places the result into this.
 Matrix4f add(Matrix4f mat2)
          Sets the value of this matrix to sum of itself and matrix m1.
 Matrix4f add(Matrix4f mat1, Matrix4f mat2)
          Sets the value of this matrix to the matrix sum of matrices m1 and m2.
 Matrix4f asReadOnly()
          
 Matrix4f clone()
          
 float determinant()
          Computes the determinant of this matrix.
 boolean epsilonEquals(Matrix4f mat2, float epsilon)
          Returns true if the L-infinite distance between this matrix and matrix m1 is less than or equal to the epsilon parameter, otherwise returns false.
 boolean equals(Matrix4f mat2)
          Returns true if all of the data members of Matrix4f m1 are equal to the corresponding data members in this Matrix4f.
 boolean equals(java.lang.Object o)
          Returns true if the Object o1 is of type Matrix4f and all of the data members of t1 are equal to the corresponding data members in this Matrix4f.
static Matrix4f fromPool()
          Allocates an Matrix4f instance from the pool.
 void get(Matrix3f mat)
          Performs an SVD normalization of this matrix in order to acquire the normalized rotational component; the values are placed into the Matrix3f parameter.
 float get(Matrix3f mat, Tuple3f pos)
          Performs an SVD normalization of this matrix to calculate the rotation as a 3x3 matrix, the translation, and the scale.
 void get(Quaternion4f quat)
          Performs an SVD normalization of this matrix in order to acquire the normalized rotational component; the values are placed into the Quat4f parameter.
 void get(Tuple3f trans)
          Retrieves the translational components of this matrix.
 void getColumn(int column, Vector4f buffer)
          Copies the matrix values in the specified column into the vector parameter.
 Matrix4f getReadOnly()
          
 void getRotationScale(Matrix3f mat)
          Gets the upper 3x3 values of this matrix and places them into the matrix mat.
 Matrix4f getRow(int row, Vector4f buffer)
          Copies the matrix values in the specified row into the vector parameter.
 float getScale()
          Performs an SVD normalization of this matrix to calculate and return the uniform scale factor.
 int hashCode()
          Returns a hash number based on the data values in this object.
 void interpolate(Matrix4f m1, Matrix4f m2, float alpha)
          Interpolates each value of this Matrix by the value alpha.
 void interpolate(Matrix4f m1, Matrix4f m2, float alpha, boolean interpolateLastLine)
          Interpolates each value of this Matrix by the value alpha.
 Matrix4f invert()
          Inverts this matrix in place.
 Matrix4f invert(Matrix4f mat)
          Sets the value of this matrix to the matrix inverse of the passed matrix m1.
 float m00()
           
 Matrix4f m00(float v)
           
 float m01()
           
 Matrix4f m01(float v)
           
 float m02()
           
 Matrix4f m02(float v)
           
 float m03()
           
 Matrix4f m03(float v)
           
 float m10()
           
 Matrix4f m10(float v)
           
 float m11()
           
 Matrix4f m11(float v)
           
 float m12()
           
 Matrix4f m12(float v)
           
 float m13()
           
 Matrix4f m13(float v)
           
 float m20()
           
 Matrix4f m20(float v)
           
 float m21()
           
 Matrix4f m21(float v)
           
 float m22()
           
 Matrix4f m22(float v)
           
 float m23()
           
 Matrix4f m23(float v)
           
 float m30()
           
 Matrix4f m30(float v)
           
 float m31()
           
 Matrix4f m31(float v)
           
 float m32()
           
 Matrix4f m32(float v)
           
 float m33()
           
 Matrix4f m33(float v)
           
 Matrix4f mul(float scalar)
          Multiplies this Matrix with a scalar.
 Matrix4f mul(float scalar, Matrix4f mat)
          Multiplies each element of matrix m1 by a scalar and places the result into this.
 Matrix4f mul(Matrix4f mat)
          Sets the value of this matrix to the result of multiplying itself with matrix mat.
 Matrix4f mul(Matrix4f mat1, Matrix4f mat2)
          Sets the value of this matrix to the result of multiplying the two argument matrices together.
 Matrix4f mulTransposeBoth(Matrix4f mat1, Matrix4f mat2)
          Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this.
 Matrix4f mulTransposeLeft(Matrix4f mat1, Matrix4f mat2)
          Multiplies the transpose of matrix m1 times matrix m2, and places the result into this.
 Matrix4f mulTransposeRight(Matrix4f mat1, Matrix4f mat2)
          Multiplies matrix m1 times the transpose of matrix m2, and places the result into this.
 Matrix4f negate(Matrix4f m1)
          Sets the value of this matrix equal to the negation of of the Matrix4f parameter.
static Matrix4f newReadOnly()
          Constructs and initializes a Matrix4f to all zeros.
static Matrix4f newReadOnly(float[] values)
          Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.
static Matrix4f newReadOnly(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
          Constructs and initializes a Matrix4f from the specified 16 values.
static Matrix4f newReadOnly(Matrix3f mat)
          Constructs a new matrix with the same values as the Matrix3f parameter.
static Matrix4f newReadOnly(Matrix4f mat)
          Constructs a new matrix with the same values as the Matrix4f parameter.
static Matrix4f newReadOnly(Quaternion4f rot, Tuple3f pos, float scale)
          Constructs and initializes a Matrix4f from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.
static Matrix4f newReadOnly(Tuple3f pos, Matrix3f rot, float scale)
          Constructs and initializes a Matrix4f from the rotation matrix, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.
 java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer)
          Reads the contents of this matrix column-wise from a FloatBuffer.
 java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer, int position)
          Reads the contents of this matrix column-wise from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(Matrix4f[] matrices, java.nio.FloatBuffer buffer)
          Reads the contents of this matrix column-wise from a FloatBuffer.
static java.nio.FloatBuffer readFromBuffer(Matrix4f[] matrices, java.nio.FloatBuffer buffer, int position)
          Reads the contents of this matrix column-wise from a FloatBuffer.
 Matrix4f rotX(float angle)
          Sets the value of this matrix to a rotation matrix about the x axis by the passed angle.
 Matrix4f rotY(float angle)
          Sets the value of this matrix to a rotation matrix about the y axis by the passed angle.
 Matrix4f rotZ(float angle)
          Sets the value of this matrix to a rotation matrix about the z axis by the passed angle.
 Matrix4f set(AxisAngle3f aa3f)
          Sets the value of this matrix to the matrix conversion of the single precision axis and angle argument.
 Matrix4f set(float scale)
          Sets the value of this matrix to a scale matrix with the passed scale amount.
 Matrix4f set(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
          Sets 16 values
 Matrix4f set(float scale, Tuple3f pos)
          Sets the value of this matrix to a scale and translation matrix; scale is not applied to the translation and all of the matrix values are modified.
 void set(Matrix3f mat)
          Sets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are initialized as if this were an identity matrix (ie, affine matrix with no translational component).
 Matrix4f set(Matrix3f mat, Tuple3f pos, float scale)
          Sets the value of this matrix from the rotation expressed by the rotation matrix m1, the translation t1, and the scale s.
 Matrix4f set(Quaternion4f quat)
          Sets the value of this matrix to the matrix conversion of the single precision quaternion argument.
 Matrix4f set(Quaternion4f quat, Tuple3f pos, float scale)
          Sets the value of this matrix from the rotation expressed by the quaternion q1, the translation t1, and the scale s.
 Matrix4f set(Tuple3f pos)
          Sets the value of this matrix to a translate matrix by the passed translation value.
 Matrix4f set(Tuple3f pos, float scale)
          Sets the value of this matrix to a scale and translation matrix; the translation is scaled by the scale factor and all of the matrix values are modified.
 Matrix4f setColumn(int column, float x, float y, float z, float w)
          Sets the specified column of this matrix4f to the four values provided.
 Matrix4f setColumn(int column, Vector4f values)
          Sets the specified column of this matrix4f to the vector provided.
 Matrix4f setInvRotation(Tuple3f tup)
          Builds an inverse rotation matrix.
 Matrix4f setRotation(AxisAngle3f aa)
          Sets the rotational component (upper 3x3) of this matrix to the matrix equivalent values of the axis-angle argument; the other elements of this matrix are unchanged; a singular value decomposition is performed on this object's upper 3x3 matrix to factor out the scale, then this object's upper 3x3 matrix components are replaced by the matrix equivalent of the axis-angle, and then the scale is reapplied to the rotational components.
 Matrix4f setRotation(Matrix3f mat)
          Sets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are unchanged; a singular value decomposition is performed on this object's upper 3x3 matrix to factor out the scale, then this object's upper 3x3 matrix components are replaced by the passed rotation components, and then the scale is reapplied to the rotational components.
 Matrix4f setRotation(Quaternion4f quat)
          Sets the rotational component (upper 3x3) of this matrix to the matrix equivalent values of the quaternion argument; the other elements of this matrix are unchanged; a singular value decomposition is performed on this object's upper 3x3 matrix to factor out the scale, then this object's upper 3x3 matrix components are replaced by the matrix equivalent of the quaternion, and then the scale is reapplied to the rotational components.
 Matrix4f setRotation(Tuple3f tup)
          Builds a rotation matrix.
 Matrix4f setRotationScale(Matrix3f mat)
          Replaces the upper 3x3 matrix values of this matrix with the values in the matrix mat.
 Matrix4f setRow(int row, float x, float y, float z, float w)
          Sets the specified row of this Matrix4f to the four values provided.
 Matrix4f setRow(int row, Vector4f values)
          Sets the specified row of this matrix4f to the Vector provided.
 Matrix4f setScale(float scale)
          Sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) from the rotational component and multiplying by the new scale.
 Matrix4f setTranslation(float transX, float transY, float transZ)
          Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.
 Matrix4f setTranslation(Tuple3f trans)
          Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.
static Matrix4f sharedSubMatrix4f(MatrixMxNf mat, int beginRow, int beginCol)
          Creates a Submatrix of mat, that begins in beginRow and beginCol.
 Matrix4f sub(Matrix4f mat2)
          Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).
 Matrix4f sub(Matrix4f mat1, Matrix4f mat2)
          Sets the value of this matrix to the matrix difference of matrices m1 and m2.
static void toPool(Matrix4f o)
          Stores the given Matrix3f instance in the pool.
 void transform(Point3f point)
          Transforms the point parameter with this Matrix4f and places the result back into point.
 void transform(Point3f point, Point3f pointOut)
          Transforms the point parameter with this Matrix4f and places the result into pointOut.
 void transform(Vector3f vec)
          Transforms the normal parameter by this transform and places the value back into normal.
 void transform(Vector3f vec, Vector3f vecOut)
          Transforms the normal parameter by this Matrix4f and places the value into normalOut.
 void transform(Vector4f vec)
          Transform the vector vec using this Matrix4f and place the result back into vec.
 void transform(Vector4f vec, Vector4f vecOut)
          Transform the vector vec using this Matrix4f and place the result into vecOut.
 Matrix4f transpose(Matrix4f mat)
          Sets the value of this matrix to the transpose of the argument matrix
 java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of this matrix column-wise to a FloatBuffer.
 java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of this matrix column-wise to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(Matrix4f[] matrices, java.nio.FloatBuffer buffer, boolean clear, boolean flip)
          Writes the contents of this matrix column-wise to a FloatBuffer.
static java.nio.FloatBuffer writeToBuffer(Matrix4f[] matrices, java.nio.FloatBuffer buffer, int position, boolean clear, boolean flip)
          Writes the contents of this matrix column-wise to a FloatBuffer.
 
Methods inherited from class org.openmali.vecmath2.MatrixMxNf
add, add, add, add, cond, copySubMatrix, deserialize, div, epsilonEquals, equals, get, get, get, get, getColumn, getColumn, getColumnMajor, getColumnMajor, getNumCols, getNumRows, getRow, getRow, getRowMajor, getRowMajor, getSerializationBufferSize, getSharedSubMatrix, getSharedSubMatrix, identityMinus, interpolate, invert, isDirty, isPositiveDefinite, isPositiveDefinite, isReadOnly, isSquare, isSubMatrix, LUD, mul, mul, mul, mul, mulComp, mulComp, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, negate, negate, newReadOnly, newReadOnly, newReadOnly, norm1, norm2, normFrobenius, normInfinity, rank, readExternal, serialize, set, set, set, set, setClean, setColumn, setColumn, setColumnMajor, setColumnMajor, setIdentity, setRow, setRow, setRowMajor, setRowMajor, setZero, sharedSubMatrixMxNf, sharedSubMatrixMxNf, solve, solve, sub, sub, sub, sub, SVD, toString, trace, transpose, transpose, writeExternal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Field Detail

ZERO

public static final Matrix4f ZERO

IDENTITY

public static final Matrix4f IDENTITY

ROT_PLUS_90_DEG_BY_X_AXIS

public static final Matrix4f ROT_PLUS_90_DEG_BY_X_AXIS

ROT_MINUS_90_DEG_BY_X_AXIS

public static final Matrix4f ROT_MINUS_90_DEG_BY_X_AXIS

ROT_PLUS_90_DEG_BY_Y_AXIS

public static final Matrix4f ROT_PLUS_90_DEG_BY_Y_AXIS

ROT_MINUS_90_DEG_BY_Y_AXIS

public static final Matrix4f ROT_MINUS_90_DEG_BY_Y_AXIS

ROT_PLUS_90_DEG_BY_Z_AXIS

public static final Matrix4f ROT_PLUS_90_DEG_BY_Z_AXIS

ROT_MINUS_90_DEG_BY_Z_AXIS

public static final Matrix4f ROT_MINUS_90_DEG_BY_Z_AXIS

Z_UP_TO_Y_UP

public static final Matrix4f Z_UP_TO_Y_UP

M

protected static final int M
See Also:
Constant Field Values

N

protected static final int N
See Also:
Constant Field Values
Constructor Detail

Matrix4f

protected Matrix4f(boolean readOnly)
Constructs and initializes a Matrix4f to all zeros.

Parameters:
readOnly -

Matrix4f

protected Matrix4f(boolean readOnly,
                   float m00,
                   float m01,
                   float m02,
                   float m03,
                   float m10,
                   float m11,
                   float m12,
                   float m13,
                   float m20,
                   float m21,
                   float m22,
                   float m23,
                   float m30,
                   float m31,
                   float m32,
                   float m33)
Constructs and initializes a Matrix4f from the specified 16 values.

Parameters:
readOnly -
m00 - the [0][0] element
m01 - the [0][1] element
m02 - the [0][2] element
m03 - the [0][3] element
m10 - the [1][0] element
m11 - the [1][1] element
m12 - the [1][2] element
m13 - the [1][3] element
m20 - the [2][0] element
m21 - the [2][1] element
m22 - the [2][2] element
m23 - the [2][3] element
m30 - the [3][0] element
m31 - the [3][1] element
m32 - the [3][2] element
m33 - the [3][3] element

Matrix4f

protected Matrix4f(boolean readOnly,
                   float[] values)
Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.

Parameters:
readOnly -
values - the array of length 16 containing in order

Matrix4f

protected Matrix4f(boolean readOnly,
                   Quaternion4f rot,
                   Tuple3f pos,
                   float scale)
Constructs and initializes a Matrix4f from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.

Parameters:
readOnly -
rot - The quaternion value representing the rotational component
pos - The translational component of the matrix
scale - The scale value applied to the rotational components

Matrix4f

protected Matrix4f(boolean readOnly,
                   Tuple3f pos,
                   Matrix3f rot,
                   float scale)
Constructs and initializes a Matrix4f from the rotation matrix, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.

Parameters:
readOnly -
pos - The translational components of the matrix
rot - The rotation matrix representing the rotational components
scale - The scale value applied to the rotational components

Matrix4f

protected Matrix4f(boolean readOnly,
                   Matrix4f mat)
Constructs a new matrix with the same values as the Matrix4f parameter.

Parameters:
readOnly -
mat - The source matrix.

Matrix4f

protected Matrix4f(boolean readOnly,
                   Matrix3f mat)
Constructs a new matrix with the same values as the Matrix3f parameter.

Parameters:
readOnly -
mat - The source matrix.

Matrix4f

protected Matrix4f(boolean readOnly,
                   int dataBegin,
                   int colSkip,
                   float[] values,
                   boolean[] isDirty)
Hidden constructor for #sharedSubMatrix3f(MatrixMxNf, int, int).

Parameters:
readOnly -
dataBegin -
colSkip -
values -
isDirty -

Matrix4f

public Matrix4f()
Constructs and initializes a Matrix4f to all zeros.


Matrix4f

public Matrix4f(float m00,
                float m01,
                float m02,
                float m03,
                float m10,
                float m11,
                float m12,
                float m13,
                float m20,
                float m21,
                float m22,
                float m23,
                float m30,
                float m31,
                float m32,
                float m33)
Constructs and initializes a Matrix4f from the specified 16 values.

Parameters:
m00 - the [0][0] element
m01 - the [0][1] element
m02 - the [0][2] element
m03 - the [0][3] element
m10 - the [1][0] element
m11 - the [1][1] element
m12 - the [1][2] element
m13 - the [1][3] element
m20 - the [2][0] element
m21 - the [2][1] element
m22 - the [2][2] element
m23 - the [2][3] element
m30 - the [3][0] element
m31 - the [3][1] element
m32 - the [3][2] element
m33 - the [3][3] element

Matrix4f

public Matrix4f(float[] values)
Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.

Parameters:
values - the array of length 16 containing in order

Matrix4f

public Matrix4f(Quaternion4f rot,
                Tuple3f pos,
                float scale)
Constructs and initializes a Matrix4f from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.

Parameters:
rot - The quaternion value representing the rotational component
pos - The translational component of the matrix
scale - The scale value applied to the rotational components

Matrix4f

public Matrix4f(Tuple3f pos,
                Matrix3f rot,
                float scale)
Constructs and initializes a Matrix4f from the rotation matrix, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.

Parameters:
pos - The translational components of the matrix
rot - The rotation matrix representing the rotational components
scale - The scale value applied to the rotational components

Matrix4f

public Matrix4f(Matrix4f mat)
Constructs a new matrix with the same values as the Matrix4f parameter.

Parameters:
mat - The source matrix.

Matrix4f

public Matrix4f(Matrix3f mat)
Constructs a new matrix with the same values as the Matrix3f parameter.

Parameters:
mat - The source matrix.

Matrix4f

protected Matrix4f(int dataBegin,
                   int colSkip,
                   float[] values,
                   boolean[] isDirty)
Hidden constructor for #sharedSubMatrix3f(MatrixMxNf, int, int).

Parameters:
dataBegin -
colSkip -
values -
isDirty -
Method Detail

m00

public final float m00()

m01

public final float m01()

m02

public final float m02()

m03

public final float m03()

m10

public final float m10()

m11

public final float m11()

m12

public final float m12()

m13

public final float m13()

m20

public final float m20()

m21

public final float m21()

m22

public final float m22()

m23

public final float m23()

m30

public final float m30()

m31

public final float m31()

m32

public final float m32()

m33

public final float m33()

m00

public final Matrix4f m00(float v)

m01

public final Matrix4f m01(float v)

m02

public final Matrix4f m02(float v)

m03

public final Matrix4f m03(float v)

m10

public final Matrix4f m10(float v)

m11

public final Matrix4f m11(float v)

m12

public final Matrix4f m12(float v)

m13

public final Matrix4f m13(float v)

m20

public final Matrix4f m20(float v)

m21

public final Matrix4f m21(float v)

m22

public final Matrix4f m22(float v)

m23

public final Matrix4f m23(float v)

m30

public final Matrix4f m30(float v)

m31

public final Matrix4f m31(float v)

m32

public final Matrix4f m32(float v)

m33

public final Matrix4f m33(float v)

set

public final Matrix4f set(float m00,
                          float m01,
                          float m02,
                          float m03,
                          float m10,
                          float m11,
                          float m12,
                          float m13,
                          float m20,
                          float m21,
                          float m22,
                          float m23,
                          float m30,
                          float m31,
                          float m32,
                          float m33)
Sets 16 values

Parameters:
m00 -
m01 -
m02 -
m03 -
m10 -
m11 -
m12 -
m13 -
m20 -
m21 -
m22 -
m23 -
m30 -
m31 -
m32 -
m33 -
Returns:
itself

set

public final Matrix4f set(float scale)
Sets the value of this matrix to a scale matrix with the passed scale amount.

Parameters:
scale - the scale factor for the matrix
Returns:
itself

set

public void set(Matrix3f mat)
Sets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are initialized as if this were an identity matrix (ie, affine matrix with no translational component).

Overrides:
set in class MatrixMxNf
Parameters:
mat - the 3x3 matrix

set

public final Matrix4f set(Tuple3f pos)
Sets the value of this matrix to a translate matrix by the passed translation value.

Parameters:
pos - the translation amount
Returns:
itself

set

public final Matrix4f set(float scale,
                          Tuple3f pos)
Sets the value of this matrix to a scale and translation matrix; scale is not applied to the translation and all of the matrix values are modified.

Parameters:
scale - the scale factor for the matrix
pos - the translation amount
Returns:
itself

set

public final Matrix4f set(Tuple3f pos,
                          float scale)
Sets the value of this matrix to a scale and translation matrix; the translation is scaled by the scale factor and all of the matrix values are modified.

Parameters:
pos - the translation amount
scale - the scale factor for the matrix
Returns:
itself

set

public final Matrix4f set(Matrix3f mat,
                          Tuple3f pos,
                          float scale)
Sets the value of this matrix from the rotation expressed by the rotation matrix m1, the translation t1, and the scale s. The translation is not modified by the scale.

Parameters:
mat - The rotation component
pos - The translation component
scale - The scale component
Returns:
itself

setTranslation

public final Matrix4f setTranslation(float transX,
                                     float transY,
                                     float transZ)
Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.

Parameters:
transX - the translational x-component
transY - the translational y-component
transZ - the translational z-component
Returns:
itself

setTranslation

public final Matrix4f setTranslation(Tuple3f trans)
Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.

Parameters:
trans - the translational component
Returns:
itself

set

public final Matrix4f set(Quaternion4f quat)
Sets the value of this matrix to the matrix conversion of the single precision quaternion argument.

Parameters:
quat - the quaternion to be converted
Returns:
itself

set

public final Matrix4f set(AxisAngle3f aa3f)
Sets the value of this matrix to the matrix conversion of the single precision axis and angle argument.

Parameters:
aa3f - the axis and angle to be converted
Returns:
itself

set

public final Matrix4f set(Quaternion4f quat,
                          Tuple3f pos,
                          float scale)
Sets the value of this matrix from the rotation expressed by the quaternion q1, the translation t1, and the scale s.

Parameters:
quat - the rotation expressed as a quaternion
pos - the translation
scale - the scale value
Returns:
itself

setScale

public final Matrix4f setScale(float scale)
Sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) from the rotational component and multiplying by the new scale.

Overrides:
setScale in class MatrixMxNf
Parameters:
scale - the new scale amount
Returns:
itself

get

public final void get(Matrix3f mat)
Performs an SVD normalization of this matrix in order to acquire the normalized rotational component; the values are placed into the Matrix3f parameter.

Overrides:
get in class MatrixMxNf
Parameters:
mat - matrix into which the rotational component is placed

get

public final float get(Matrix3f mat,
                       Tuple3f pos)
Performs an SVD normalization of this matrix to calculate the rotation as a 3x3 matrix, the translation, and the scale. None of the matrix values are modified.

Parameters:
mat - The normalized matrix representing the rotation
pos - The translation component
Returns:
The scale component of this transform

get

public final void get(Quaternion4f quat)
Performs an SVD normalization of this matrix in order to acquire the normalized rotational component; the values are placed into the Quat4f parameter.

Parameters:
quat - quaternion into which the rotation component is placed

writeToBuffer

public java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer,
                                          boolean clear,
                                          boolean flip)
Writes the contents of this matrix column-wise to a FloatBuffer.

Parameters:
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?
Returns:
itself

writeToBuffer

public java.nio.FloatBuffer writeToBuffer(java.nio.FloatBuffer buffer,
                                          int position,
                                          boolean clear,
                                          boolean flip)
Writes the contents of this matrix column-wise to a FloatBuffer.

Parameters:
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?
Returns:
itself

writeToBuffer

public static java.nio.FloatBuffer writeToBuffer(Matrix4f[] matrices,
                                                 java.nio.FloatBuffer buffer,
                                                 boolean clear,
                                                 boolean flip)
Writes the contents of this matrix column-wise to a FloatBuffer.

Parameters:
matrices -
buffer -
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?
Returns:
itself

writeToBuffer

public static java.nio.FloatBuffer writeToBuffer(Matrix4f[] matrices,
                                                 java.nio.FloatBuffer buffer,
                                                 int position,
                                                 boolean clear,
                                                 boolean flip)
Writes the contents of this matrix column-wise to a FloatBuffer.

Parameters:
matrices -
buffer -
position - position in the buffer
clear - clear the buffer before writing data?
flip - flip the buffer after writing data?
Returns:
itself

readFromBuffer

public java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer)
Reads the contents of this matrix column-wise from a FloatBuffer.

Parameters:
buffer -
Returns:
itself

readFromBuffer

public java.nio.FloatBuffer readFromBuffer(java.nio.FloatBuffer buffer,
                                           int position)
Reads the contents of this matrix column-wise from a FloatBuffer.

Parameters:
buffer -
position - position in the buffer
Returns:
itself

readFromBuffer

public static java.nio.FloatBuffer readFromBuffer(Matrix4f[] matrices,
                                                  java.nio.FloatBuffer buffer)
Reads the contents of this matrix column-wise from a FloatBuffer.

Parameters:
matrices -
buffer -
Returns:
itself

readFromBuffer

public static java.nio.FloatBuffer readFromBuffer(Matrix4f[] matrices,
                                                  java.nio.FloatBuffer buffer,
                                                  int position)
Reads the contents of this matrix column-wise from a FloatBuffer.

Parameters:
matrices -
buffer -
position - position in the buffer
Returns:
itself

get

public final void get(Tuple3f trans)
Retrieves the translational components of this matrix.

Parameters:
trans - the vector that will receive the translational component

getRotationScale

public final void getRotationScale(Matrix3f mat)
Gets the upper 3x3 values of this matrix and places them into the matrix mat.

Parameters:
mat - The matrix that will hold the values

getScale

public final float getScale()
Performs an SVD normalization of this matrix to calculate and return the uniform scale factor. This matrix is not modified.

Returns:
the scale factor of this matrix

setRotationScale

public final Matrix4f setRotationScale(Matrix3f mat)
Replaces the upper 3x3 matrix values of this matrix with the values in the matrix mat.

Parameters:
mat - The matrix that will be the new upper 3x3
Returns:
itself

setRow

public final Matrix4f setRow(int row,
                             float x,
                             float y,
                             float z,
                             float w)
Sets the specified row of this Matrix4f to the four values provided.

Parameters:
row - the row number to be modified (zero indexed)
x - the first column element
y - the second column element
z - the third column element
w - the fourth column element
Returns:
itself

setRow

public final Matrix4f setRow(int row,
                             Vector4f values)
Sets the specified row of this matrix4f to the Vector provided.

Parameters:
row - the row number to be modified (zero indexed)
values - the replacement row
Returns:
itself

getRow

public final Matrix4f getRow(int row,
                             Vector4f buffer)
Copies the matrix values in the specified row into the vector parameter.

Parameters:
row - the matrix row
buffer - The vector into which the matrix row values will be copied
Returns:
itself

setColumn

public final Matrix4f setColumn(int column,
                                float x,
                                float y,
                                float z,
                                float w)
Sets the specified column of this matrix4f to the four values provided.

Parameters:
column - the column number to be modified (zero indexed)
x - the first row element
y - the second row element
z - the third row element
w - the fourth row element
Returns:
itself

setColumn

public final Matrix4f setColumn(int column,
                                Vector4f values)
Sets the specified column of this matrix4f to the vector provided.

Parameters:
column - the column number to be modified (zero indexed)
values - the replacement column
Returns:
itself

getColumn

public final void getColumn(int column,
                            Vector4f buffer)
Copies the matrix values in the specified column into the vector parameter.

Parameters:
column - the matrix column
buffer - The vector into which the matrix column values will be copied

determinant

public final float determinant()
Computes the determinant of this matrix.

Returns:
the determinant of the matrix

transpose

public final Matrix4f transpose(Matrix4f mat)
Sets the value of this matrix to the transpose of the argument matrix

Parameters:
mat - the matrix to be transposed
Returns:
itself

negate

public final Matrix4f negate(Matrix4f m1)
Sets the value of this matrix equal to the negation of of the Matrix4f parameter.

Parameters:
m1 - The source matrix
Returns:
itself

invert

public Matrix4f invert()
Inverts this matrix in place.

Overrides:
invert in class MatrixMxNf
Returns:
itself

invert

public final Matrix4f invert(Matrix4f mat)
Sets the value of this matrix to the matrix inverse of the passed matrix m1.

Parameters:
mat - the matrix to be inverted
Returns:
itself

add

public final Matrix4f add(float scalar,
                          Matrix4f mat)
Adds a scalar to each component of the matrix m1 and places the result into this. Matrix m1 is not modified.

Parameters:
scalar - The scalar adder.
mat - The original matrix values.
Returns:
itself

add

public final Matrix4f add(Matrix4f mat1,
                          Matrix4f mat2)
Sets the value of this matrix to the matrix sum of matrices m1 and m2.

Parameters:
mat1 - the first matrix
mat2 - the second matrix
Returns:
itself

add

public final Matrix4f add(Matrix4f mat2)
Sets the value of this matrix to sum of itself and matrix m1.

Parameters:
mat2 - the other matrix
Returns:
itself

sub

public final Matrix4f sub(Matrix4f mat2)
Sets the value of this matrix to the matrix difference of itself and matrix m1 (this = this - m1).

Parameters:
mat2 - the other matrix
Returns:
itself

sub

public final Matrix4f sub(Matrix4f mat1,
                          Matrix4f mat2)
Sets the value of this matrix to the matrix difference of matrices m1 and m2.

Parameters:
mat1 - the first matrix
mat2 - the second matrix
Returns:
itself

rotX

public final Matrix4f rotX(float angle)
Sets the value of this matrix to a rotation matrix about the x axis by the passed angle.

Parameters:
angle - the angle to rotate about the X axis in radians
Returns:
itself

rotY

public final Matrix4f rotY(float angle)
Sets the value of this matrix to a rotation matrix about the y axis by the passed angle.

Parameters:
angle - the angle to rotate about the Y axis in radians
Returns:
itself

rotZ

public final Matrix4f rotZ(float angle)
Sets the value of this matrix to a rotation matrix about the z axis by the passed angle.

Parameters:
angle - the angle to rotate about the Z axis in radians
Returns:
itself

mul

public Matrix4f mul(float scalar)
Multiplies this Matrix with a scalar.

Overrides:
mul in class MatrixMxNf
Returns:
itself

mul

public final Matrix4f mul(float scalar,
                          Matrix4f mat)
Multiplies each element of matrix m1 by a scalar and places the result into this. Matrix mat is not modified.

Parameters:
scalar - The scalar multiplier.
mat - The original matrix.
Returns:
itself

mul

public final Matrix4f mul(Matrix4f mat)
Sets the value of this matrix to the result of multiplying itself with matrix mat.

Parameters:
mat - the other matrix
Returns:
itself

mul

public Matrix4f mul(Matrix4f mat1,
                    Matrix4f mat2)
Sets the value of this matrix to the result of multiplying the two argument matrices together.

Parameters:
mat1 - the first matrix
mat2 - the second matrix
Returns:
itself

mulTransposeBoth

public final Matrix4f mulTransposeBoth(Matrix4f mat1,
                                       Matrix4f mat2)
Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this.

Parameters:
mat1 - The matrix on the left hand side of the multiplication
mat2 - The matrix on the right hand side of the multiplication
Returns:
itself

mulTransposeLeft

public final Matrix4f mulTransposeLeft(Matrix4f mat1,
                                       Matrix4f mat2)
Multiplies the transpose of matrix m1 times matrix m2, and places the result into this.

Parameters:
mat1 - The matrix on the left hand side of the multiplication
mat2 - The matrix on the right hand side of the multiplication
Returns:
itself

mulTransposeRight

public final Matrix4f mulTransposeRight(Matrix4f mat1,
                                        Matrix4f mat2)
Multiplies matrix m1 times the transpose of matrix m2, and places the result into this.

Parameters:
mat1 - The matrix on the left hand side of the multiplication
mat2 - The matrix on the right hand side of the multiplication
Returns:
itself

transform

public final void transform(Vector4f vec,
                            Vector4f vecOut)
Transform the vector vec using this Matrix4f and place the result into vecOut.

Parameters:
vec - the single precision vector to be transformed
vecOut - the vector into which the transformed values are placed

transform

public final void transform(Vector4f vec)
Transform the vector vec using this Matrix4f and place the result back into vec.

Parameters:
vec - the single precision vector to be transformed

transform

public final void transform(Point3f point,
                            Point3f pointOut)
Transforms the point parameter with this Matrix4f and places the result into pointOut. The fourth element of the point input paramter is assumed to be one.

Parameters:
point - the input point to be transformed.
pointOut - the transformed point

transform

public final void transform(Point3f point)
Transforms the point parameter with this Matrix4f and places the result back into point. The fourth element of the point input paramter is assumed to be one.

Parameters:
point - the input point to be transformed.

transform

public final void transform(Vector3f vec,
                            Vector3f vecOut)
Transforms the normal parameter by this Matrix4f and places the value into normalOut. The fourth element of the normal is assumed to be zero.

Parameters:
vec - the input normal to be transformed.
vecOut - the transformed normal

transform

public final void transform(Vector3f vec)
Transforms the normal parameter by this transform and places the value back into normal. The fourth element of the normal is assumed to be zero.

Parameters:
vec - the input normal to be transformed.

setRotation

public final Matrix4f setRotation(Matrix3f mat)
Sets the rotational component (upper 3x3) of this matrix to the matrix values in the single precision Matrix3f argument; the other elements of this matrix are unchanged; a singular value decomposition is performed on this object's upper 3x3 matrix to factor out the scale, then this object's upper 3x3 matrix components are replaced by the passed rotation components, and then the scale is reapplied to the rotational components.

Parameters:
mat - single precision 3x3 matrix
Returns:
itself

setRotation

public final Matrix4f setRotation(Quaternion4f quat)
Sets the rotational component (upper 3x3) of this matrix to the matrix equivalent values of the quaternion argument; the other elements of this matrix are unchanged; a singular value decomposition is performed on this object's upper 3x3 matrix to factor out the scale, then this object's upper 3x3 matrix components are replaced by the matrix equivalent of the quaternion, and then the scale is reapplied to the rotational components.

Parameters:
quat - the quaternion that specifies the rotation
Returns:
itself

setRotation

public final Matrix4f setRotation(AxisAngle3f aa)
Sets the rotational component (upper 3x3) of this matrix to the matrix equivalent values of the axis-angle argument; the other elements of this matrix are unchanged; a singular value decomposition is performed on this object's upper 3x3 matrix to factor out the scale, then this object's upper 3x3 matrix components are replaced by the matrix equivalent of the axis-angle, and then the scale is reapplied to the rotational components.

Parameters:
aa - the axis-angle to be converted (x, y, z, angle)
Returns:
itself

setRotation

public final Matrix4f setRotation(Tuple3f tup)
Builds a rotation matrix.

Parameters:
tup -
Returns:
itself

setInvRotation

public final Matrix4f setInvRotation(Tuple3f tup)
Builds an inverse rotation matrix.

Parameters:
tup -
Returns:
itself

interpolate

public void interpolate(Matrix4f m1,
                        Matrix4f m2,
                        float alpha,
                        boolean interpolateLastLine)
Interpolates each value of this Matrix by the value alpha. Mxy = M1xy + ( ( M2xy - M1xy ) * alpha )

Parameters:
m1 -
m2 -
alpha -
interpolateLastLine -

interpolate

public final void interpolate(Matrix4f m1,
                              Matrix4f m2,
                              float alpha)
Interpolates each value of this Matrix by the value alpha. Mxy = M1xy + ( ( M2xy - M1xy ) * alpha )

Parameters:
m1 -
m2 -
alpha -

hashCode

public int hashCode()
Returns a hash number based on the data values in this object. Two different Matrix4f objects with identical data values (ie, returns true for equals(Matrix4f) ) will return the same hash number. Two objects with different data members may return the same hash value, although this is not likely.

Overrides:
hashCode in class MatrixMxNf
Returns:
the integer hash value

equals

public boolean equals(Matrix4f mat2)
Returns true if all of the data members of Matrix4f m1 are equal to the corresponding data members in this Matrix4f.

Parameters:
mat2 - The matrix with which the comparison is made.
Returns:
true or false

equals

public boolean equals(java.lang.Object o)
Returns true if the Object o1 is of type Matrix4f and all of the data members of t1 are equal to the corresponding data members in this Matrix4f.

Overrides:
equals in class MatrixMxNf
Parameters:
o - the object with which the comparison is made.

epsilonEquals

public boolean epsilonEquals(Matrix4f mat2,
                             float epsilon)
Returns true if the L-infinite distance between this matrix and matrix m1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[i=0,1,2,3 ; j=0,1,2,3 ; abs(this.m(i,j) - m1.m(i,j)]

Parameters:
mat2 - The matrix to be compared to this matrix
epsilon - the threshold value

clone

public Matrix4f clone()

Overrides:
clone in class MatrixMxNf

asReadOnly

public Matrix4f asReadOnly()

Overrides:
asReadOnly in class MatrixMxNf
Returns:
a new instance sharing the values array with this instance. The new instance is read-only. Changes to this instance will be reflected in the new read-only-instance.
See Also:
MatrixMxNf.getReadOnly()

getReadOnly

public Matrix4f getReadOnly()

Overrides:
getReadOnly in class MatrixMxNf
Returns:
a single instance sharing the values array with this instance (one unique instance per 'master-instance'). The instance is read-only. Changes to this instance will be reflected in the read-only-instance.
See Also:
MatrixMxNf.asReadOnly()

newReadOnly

public static Matrix4f newReadOnly()
Constructs and initializes a Matrix4f to all zeros.


newReadOnly

public static Matrix4f newReadOnly(float m00,
                                   float m01,
                                   float m02,
                                   float m03,
                                   float m10,
                                   float m11,
                                   float m12,
                                   float m13,
                                   float m20,
                                   float m21,
                                   float m22,
                                   float m23,
                                   float m30,
                                   float m31,
                                   float m32,
                                   float m33)
Constructs and initializes a Matrix4f from the specified 16 values.

Parameters:
m00 - the [0][0] element
m01 - the [0][1] element
m02 - the [0][2] element
m03 - the [0][3] element
m10 - the [1][0] element
m11 - the [1][1] element
m12 - the [1][2] element
m13 - the [1][3] element
m20 - the [2][0] element
m21 - the [2][1] element
m22 - the [2][2] element
m23 - the [2][3] element
m30 - the [3][0] element
m31 - the [3][1] element
m32 - the [3][2] element
m33 - the [3][3] element

newReadOnly

public static Matrix4f newReadOnly(float[] values)
Constructs and initializes a Matrix4f from the specified 16 element array. this.m00 =v[0], this.m01=v[1], etc.

Parameters:
values - the array of length 16 containing in order

newReadOnly

public static Matrix4f newReadOnly(Quaternion4f rot,
                                   Tuple3f pos,
                                   float scale)
Constructs and initializes a Matrix4f from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.

Parameters:
rot - The quaternion value representing the rotational component
pos - The translational component of the matrix
scale - The scale value applied to the rotational components

newReadOnly

public static Matrix4f newReadOnly(Tuple3f pos,
                                   Matrix3f rot,
                                   float scale)
Constructs and initializes a Matrix4f from the rotation matrix, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components.

Parameters:
pos - The translational components of the matrix
rot - The rotation matrix representing the rotational components
scale - The scale value applied to the rotational components

newReadOnly

public static Matrix4f newReadOnly(Matrix4f mat)
Constructs a new matrix with the same values as the Matrix4f parameter.

Parameters:
mat - The source matrix.

newReadOnly

public static Matrix4f newReadOnly(Matrix3f mat)
Constructs a new matrix with the same values as the Matrix3f parameter.

Parameters:
mat - The source matrix.

sharedSubMatrix4f

public static Matrix4f sharedSubMatrix4f(MatrixMxNf mat,
                                         int beginRow,
                                         int beginCol)
Creates a Submatrix of mat, that begins in beginRow and beginCol.
Example: let mat be a 4x4 matrix, and we want to have a 2x2 submatrix at position (1,2):
x x x x
x x y y
x x y y
x x x x
the y's mark the fetched Submatrix.
The produced submatrix works on the same data array as mat, so changes are seen on the other one respectively.

Parameters:
mat - the parent matrix
beginRow - the row to start this matrix at
beginCol - the column to start this matrix at
Returns:
the new shared submatrix
See Also:
#Matrix4f(int, int, float[])

fromPool

public static Matrix4f fromPool()
Allocates an Matrix4f instance from the pool.


toPool

public static void toPool(Matrix4f o)
Stores the given Matrix3f instance in the pool.

Parameters:
o -