Top Description Fields Constructors Methods
javax.vecmath

public Class Matrix4f

extends Object
implements Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable
Imports
java.lang.Math

A single precision floating point 4 by 4 matrix. Primarily to support 3D rotations.

Field Summary

Modifier and TypeField and Description
private static final double
public float
m00

The first element of the first row.

public float
m01

The second element of the first row.

public float
m02

The third element of the first row.

public float
m03

The fourth element of the first row.

public float
m10

The first element of the second row.

public float
m11

The second element of the second row.

public float
m12

The third element of the second row.

public float
m13

The fourth element of the second row.

public float
m20

The first element of the third row.

public float
m21

The second element of the third row.

public float
m22

The third element of the third row.

public float
m23

The fourth element of the third row.

public float
m30

The first element of the fourth row.

public float
m31

The second element of the fourth row.

public float
m32

The third element of the fourth row.

public float
m33

The fourth element of the fourth row.

pack-priv static final long

Constructor Summary

AccessConstructor and Description
public
Matrix4f(float
the [0][0] element
m00
,
float
the [0][1] element
m01
,
float
the [0][2] element
m02
,
float
the [0][3] element
m03
,
float
the [1][0] element
m10
,
float
the [1][1] element
m11
,
float
the [1][2] element
m12
,
float
the [1][3] element
m13
,
float
the [2][0] element
m20
,
float
the [2][1] element
m21
,
float
the [2][2] element
m22
,
float
the [2][3] element
m23
,
float
the [3][0] element
m30
,
float
the [3][1] element
m31
,
float
the [3][2] element
m32
,
float
the [3][3] element
m33
)

Constructs and initializes a Matrix4f from the specified 16 values.

public
Matrix4f(float[]
the array of length 16 containing in order
v
)

Constructs and initializes a Matrix4f from the specified 16 element array.

public
Matrix4f(Quat4f
the quaternion value representing the rotational component
q1
,
Vector3f
the translational component of the matrix
t1
,
float
the scale value applied to the rotational components
s
)

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.

public
Matrix4f(Matrix4d
the source matrix
m1
)

Constructs a new matrix with the same values as the Matrix4d parameter.

public
Matrix4f(Matrix4f
the source matrix
m1
)

Constructs a new matrix with the same values as the Matrix4f parameter.

public
Matrix4f(Matrix3f
the rotation matrix representing the rotational components
m1
,
Vector3f
the translational components of the matrix
t1
,
float
the scale value applied to the rotational components
s
)

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 of the matrix.

public
Matrix4f()

Constructs and initializes a Matrix4f to all zeros.

Method Summary

Modifier and TypeMethod and Description
public final void
add(float
the scalar adder
scalar
)

Adds a scalar to each component of this matrix.

public final void
add(float
the scalar adder
scalar
,
Matrix4f
the original matrix values
m1
)

Adds a scalar to each component of the matrix m1 and places the result into this.

public final void
add(Matrix4f
the first matrix
m1
,
Matrix4f
the second matrix
m2
)

Sets the value of this matrix to the matrix sum of matrices m1 and m2.

public final void
add(Matrix4f
the other matrix
m1
)

Sets the value of this matrix to the sum of itself and matrix m1.

public Object

Returns:

a clone of this instance.
clone
()

Overrides java.lang.Object.clone.

Creates a new object of the same class as this object.
public final float

Returns:

the determinate of the matrix
determinant
()

Computes the determinate of this matrix.

public boolean
epsilonEquals(Matrix4f
the matrix to be compared to this matrix
m1
,
float
the threshold value
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.

public boolean

Returns:

true or false
equals
(Matrix4f
the matrix with which the comparison is made.
m1
)

Returns true if all of the data members of Matrix4f m1 are equal to the corresponding data members in this Matrix4f.

public boolean

Returns:

true or false
equals
(Object
the matrix with which the comparison is made.
t1
)

Overrides java.lang.Object.equals.

Returns true if the Object t1 is of type Matrix4f and all of the data members of t1 are equal to the corresponding data members in this Matrix4f.
public final void
get(Matrix3d
matrix into which the rotational component is placed
m1
)

Performs an SVD normalization of this matrix in order to acquire the normalized rotational component; the values are placed into the Matrix3d parameter.

public final void
get(Matrix3f
matrix into which the rotational component is placed
m1
)

Performs an SVD normalization of this matrix in order to acquire the normalized rotational component; the values are placed into the Matrix3f parameter.

public final float

Returns:

the scale component of this transform
get
(Matrix3f
the normalized matrix representing the rotation
m1
,
Vector3f
the translation component
t1
)

Performs an SVD normalization of this matrix to calculate the rotation as a 3x3 matrix, the translation, and the scale.

public final void
get(Quat4f
quaternion into which the rotation component is placed
q1
)

Performs an SVD normalization of this matrix in order to acquire the normalized rotational component; the values are placed into the Quat4f parameter.

public final void
get(Vector3f
the vector that will receive the translational component
trans
)

Retrieves the translational components of this matrix.

public final void
getColumn(int
the matrix column
column
,
Vector4f
the vector into which the matrix row values will be copied
v
)

Copies the matrix values in the specified column into the vector parameter.

public final void
getColumn(int
the matrix column
column
,
float[]
the array into which the matrix row values will be copied
v
)

Copies the matrix values in the specified column into the array parameter.

public final float

Returns:

the value at the indexed element
getElement
(int
the row number to be retrieved (zero indexed)
row
,
int
the column number to be retrieved (zero indexed)
column
)

Retrieves the value at the specified row and column of this matrix.

public final float

Returns:

Returns the m00.
getM00
()

Get the first matrix element in the first row.

public final float

Returns:

Returns the m01.
getM01
()

Get the second matrix element in the first row.

public final float

Returns:

Returns the m02.
getM02
()

Get the third matrix element in the first row.

public final float

Returns:

Returns the m03.
getM03
()

Get the fourth element of the first row.

public final float

Returns:

Returns the m10.
getM10
()

Get first matrix element in the second row.

public final float

Returns:

Returns the m11.
getM11
()

Get second matrix element in the second row.

public final float

Returns:

Returns the m12.
getM12
()

Get the third matrix element in the second row.

public final float

Returns:

Returns the m13.
getM13
()

Get the fourth element of the second row.

public final float

Returns:

Returns the m20.
getM20
()

Get the first matrix element in the third row.

public final float

Returns:

Returns the m21.
getM21
()

Get the second matrix element in the third row.

public final float

Returns:

Returns the m22.
getM22
()

Get the third matrix element in the third row.

public final float

Returns:

Returns the m23.
getM23
()

Get the fourth element of the third row.

public final float

Returns:

Returns the m30.
getM30
()

Get the first element of the fourth row.

public final float

Returns:

Returns the m31.
getM31
()

Get the second element of the fourth row.

public final float

Returns:

Returns the m32.
getM32
()

Get the third element of the fourth row.

public final float

Returns:

Returns the m33.
getM33
()

Get the fourth element of the fourth row.

public final void
getRotationScale(Matrix3f
the matrix that will hold the values
m1
)

Gets the upper 3x3 values of this matrix and places them into the matrix m1.

public final void
getRow(int
the matrix row
row
,
Vector4f
the vector into which the matrix row values will be copied
v
)

Copies the matrix values in the specified row into the vector parameter.

public final void
getRow(int
the matrix row
row
,
float[]
the array into which the matrix row values will be copied
v
)

Copies the matrix values in the specified row into the array parameter.

public final float

Returns:

the scale factor of this matrix
getScale
()

Performs an SVD normalization of this matrix to calculate and return the uniform scale factor.

private final void
getScaleRotate(double[] scales, double[] rots)

public int

Returns:

the integer hash code value
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value based on the data values in this object.
public final void
invert(Matrix4f
the matrix to be inverted
m1
)

Sets the value of this matrix to the matrix inverse of the passed (user declared) matrix m1.

public final void
invert()

Inverts this matrix in place.

pack-priv final void
invertGeneral(Matrix4f m1)

General invert routine.

pack-priv static void
luBacksubstitution(double[] matrix1, int[] row_perm, double[] matrix2)

Solves a set of linear equations.

pack-priv static boolean

Returns:

true if the matrix is nonsingular, or false otherwise.
luDecomposition
(double[] matrix0, int[] row_perm)

Given a 4x4 array "matrix0", this function replaces it with the LU decomposition of a row-wise permutation of itself.

public final void
mul(float
the scalar multiplier.
scalar
)

Multiplies each element of this matrix by a scalar.

public final void
mul(float
the scalar multiplier.
scalar
,
Matrix4f
the original matrix.
m1
)

Multiplies each element of matrix m1 by a scalar and places the result into this.

public final void
mul(Matrix4f
the other matrix
m1
)

Sets the value of this matrix to the result of multiplying itself with matrix m1.

public final void
mul(Matrix4f
the first matrix
m1
,
Matrix4f
the second matrix
m2
)

Sets the value of this matrix to the result of multiplying the two argument matrices together.

public final void
mulTransposeBoth(Matrix4f
the matrix on the left hand side of the multiplication
m1
,
Matrix4f
the matrix on the right hand side of the multiplication
m2
)

Multiplies the transpose of matrix m1 times the transpose of matrix m2, and places the result into this.

public final void
mulTransposeLeft(Matrix4f
the matrix on the left hand side of the multiplication
m1
,
Matrix4f
the matrix on the right hand side of the multiplication
m2
)

Multiplies the transpose of matrix m1 times matrix m2, and places the result into this.

public final void
mulTransposeRight(Matrix4f
the matrix on the left hand side of the multiplication
m1
,
Matrix4f
the matrix on the right hand side of the multiplication
m2
)

Multiplies matrix m1 times the transpose of matrix m2, and places the result into this.

public final void
negate()

Negates the value of this matrix: this = -this.

public final void
negate(Matrix4f
the source matrix
m1
)

Sets the value of this matrix equal to the negation of of the Matrix4f parameter.

public final void
rotX(float
the angle to rotate about the X axis in radians
angle
)

Sets the value of this matrix to a counter clockwise rotation about the x axis.

public final void
rotY(float
the angle to rotate about the Y axis in radians
angle
)

Sets the value of this matrix to a counter clockwise rotation about the y axis.

public final void
rotZ(float
the angle to rotate about the Z axis in radians
angle
)

Sets the value of this matrix to a counter clockwise rotation about the z axis.

public final void
set(Quat4f
the quaternion to be converted
q1
)

Sets the value of this matrix to the matrix conversion of the single precision quaternion argument.

public final void
set(AxisAngle4f
the axis and angle to be converted
a1
)

Sets the value of this matrix to the matrix conversion of the (single precision) axis and angle argument.

public final void
set(Quat4d
the quaternion to be converted
q1
)

Sets the value of this matrix to the matrix conversion of the double precision quaternion argument.

public final void
set(AxisAngle4d
the axis and angle to be converted
a1
)

Sets the value of this matrix to the matrix conversion of the double precision axis and angle argument.

public final void
set(Quat4d
the rotation expressed as a quaternion
q1
,
Vector3d
the translation
t1
,
double
the scale value
s
)

Sets the value of this matrix from the rotation expressed by the quaternion q1, the translation t1, and the scale s.

public final void
set(Quat4f
the rotation expressed as a quaternion
q1
,
Vector3f
the translation
t1
,
float
the scale value
s
)

Sets the value of this matrix from the rotation expressed by the quaternion q1, the translation t1, and the scale s.

public final void
set(Matrix4d
the matrix4d to be converted to float
m1
)

Sets the value of this matrix to the float value of the passed matrix4d m1.

public final void
set(Matrix4f
the matrix to be copied
m1
)

Sets the value of this matrix to a copy of the passed matrix m1.

public final void
set(Matrix3f
the single-precision 3x3 matrix
m1
)

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 (i.e., affine matrix with no translational component).

public final void
set(Matrix3d
the double-precision 3x3 matrix
m1
)

Sets the rotational component (upper 3x3) of this matrix to the matrix values in the double precision Matrix3d argument; the other elements of this matrix are initialized as if this were an identity matrix (i.e., affine matrix with no translational component).

public final void
set(float
the scale factor for the matrix
scale
)

Sets the value of this matrix to a scale matrix with the the passed scale amount.

public final void
set(float[]
the single precision array of length 16
m
)

Sets the values in this Matrix4f equal to the row-major array parameter (ie, the first four elements of the array will be copied into the first row of this matrix, etc.).

public final void
set(Vector3f
the translation amount
v1
)

Sets the value of this matrix to a translate matrix with the passed translation value.

public final void
set(float
the scale factor for the matrix
scale
,
Vector3f
the translation amount
t1
)

Sets the value of this transform to a scale and translation matrix; the scale is not applied to the translation and all of the matrix values are modified.

public final void
set(Vector3f
the translation amount
t1
,
float
the scale factor for the matrix
scale
)

Sets the value of this transform to a scale and translation matrix; the translation is scaled by the scale factor and all of the matrix values are modified.

public final void
set(Matrix3f
the rotation component
m1
,
Vector3f
the translation component
t1
,
float
the scale component
scale
)

Sets the value of this matrix from the rotation expressed by the rotation matrix m1, the translation t1, and the scale factor.

public final void
set(Matrix3d
the rotation component
m1
,
Vector3d
the translation component
t1
,
double
the scale factor
scale
)

Sets the value of this matrix from the rotation expressed by the rotation matrix m1, the translation t1, and the scale factor.

public final void
setColumn(int
the column number to be modified (zero indexed)
column
,
float
the first row element
x
,
float
the second row element
y
,
float
the third row element
z
,
float
the fourth row element
w
)

Sets the specified column of this matrix4f to the four values provided.

public final void
setColumn(int
the column number to be modified (zero indexed)
column
,
Vector4f
the replacement column
v
)

Sets the specified column of this matrix4f to the vector provided.

public final void
setColumn(int
the column number to be modified (zero indexed)
column
,
float[]
the replacement column
v
)

Sets the specified column of this matrix4f to the four values provided.

public final void
setElement(int
the row number to be modified (zero indexed)
row
,
int
the column number to be modified (zero indexed)
column
,
float
the new value
value
)

Sets the specified element of this matrix4f to the value provided.

public final void
setIdentity()

Sets this Matrix4f to identity.

public final void
setM00(float
The m00 to set.
m00
)

Set the first matrix element in the first row.

public final void
setM01(float
The m01 to set.
m01
)

Set the second matrix element in the first row.

public final void
setM02(float
The m02 to set.
m02
)

Set the third matrix element in the first row.

public final void
setM03(float
The m03 to set.
m03
)

Set the fourth element of the first row.

public final void
setM10(float
The m10 to set.
m10
)

Set first matrix element in the second row.

public final void
setM11(float
The m11 to set.
m11
)

Set the second matrix element in the second row.

public final void
setM12(float
The m12 to set.
m12
)

Set the third matrix element in the second row.

public final void
setM13(float
The m13 to set.
m13
)

Set the fourth element of the second row.

public final void
setM20(float
The m20 to set.
m20
)

Set the first matrix element in the third row.

public final void
setM21(float
The m21 to set.
m21
)

Set the second matrix element in the third row.

public final void
setM22(float
The m22 to set.
m22
)

Set the third matrix element in the third row.

public final void
setM23(float
The m23 to set.
m23
)

Set the fourth element of the third row.

public final void
setM30(float
The m30 to set.
m30
)

Set the first element of the fourth row.

public final void
setM31(float
The m31 to set.
m31
)

Set the second element of the fourth row.

public final void
setM32(float
The m32 to set.
m32
)

Set the third element of the fourth row.

public final void
setM33(float
The m33 to set.
m33
)

Set the fourth element of the fourth row.

public final void
setRotation(Matrix3d
double precision 3x3 matrix
m1
)

Sets the rotational component (upper 3x3) of this matrix to the matrix values in the double precision Matrix3d 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.

public final void
setRotation(Matrix3f
single precision 3x3 matrix
m1
)

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.

public final void
setRotation(Quat4f
the quaternion that specifies the rotation
q1
)

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.

public final void
setRotation(Quat4d
the quaternion that specifies the rotation
q1
)

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.

public final void
setRotation(AxisAngle4f
the axis-angle to be converted (x, y, z, angle)
a1
)

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.

public final void
setRotationScale(Matrix3f
the matrix that will be the new upper 3x3
m1
)

Replaces the upper 3x3 matrix values of this matrix with the values in the matrix m1.

public final void
setRow(int
the row number to be modified (zero indexed)
row
,
float
the first column element
x
,
float
the second column element
y
,
float
the third column element
z
,
float
the fourth column element
w
)

Sets the specified row of this matrix4f to the four values provided.

public final void
setRow(int
the row number to be modified (zero indexed)
row
,
Vector4f
the replacement row
v
)

Sets the specified row of this matrix4f to the Vector provided.

public final void
setRow(int
the row number to be modified (zero indexed)
row
,
float[]
the replacement row
v
)

Sets the specified row of this matrix4f to the four values provided in the passed array.

public final void
setScale(float
the new scale amount
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.

public final void
setTranslation(Vector3f
the translational component
trans
)

Modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.

public final void
setZero()

Sets this matrix to all zeros.

public final void
sub(Matrix4f
the first matrix
m1
,
Matrix4f
the second matrix
m2
)

Performs an element-by-element subtraction of matrix m2 from matrix m1 and places the result into matrix this (this = m2 - m1).

public final void
sub(Matrix4f
the other matrix
m1
)

Sets this matrix to the matrix difference of itself and matrix m1 (this = this - m1).

public String

Returns:

the String representation
toString
()

Overrides java.lang.Object.toString.

Returns a string that contains the values of this Matrix4f.
public final void
transform(Tuple4f
the single precision vector to be transformed
vec
,
Tuple4f
the vector into which the transformed values are placed
vecOut
)

Transform the vector vec using this Matrix4f and place the result into vecOut.

public final void
transform(Tuple4f
the single precision vector to be transformed
vec
)

Transform the vector vec using this Transform and place the result back into vec.

public final void
transform(Point3f
the input point to be transformed.
point
,
Point3f
the transformed point
pointOut
)

Transforms the point parameter with this Matrix4f and places the result into pointOut.

public final void
transform(Point3f
the input point to be transformed.
point
)

Transforms the point parameter with this Matrix4f and places the result back into point.

public final void
transform(Vector3f
the input normal to be transformed.
normal
,
Vector3f
the transformed normal
normalOut
)

Transforms the normal parameter by this Matrix4f and places the value into normalOut.

public final void
transform(Vector3f
the input normal to be transformed.
normal
)

Transforms the normal parameter by this transform and places the value back into normal.

public final void
transpose()

Sets the value of this matrix to its transpose in place.

public final void
transpose(Matrix4f
the matrix to be transposed
m1
)

Sets the value of this matrix to the transpose of the argument matrix.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait