Package com.jme3.math
Class Matrix4f
java.lang.Object
com.jme3.math.Matrix4f
- All Implemented Interfaces:
Cloneable
A 4x4 matrix composed of 16 single-precision elements, used to represent
linear or perspective transformations of 3-D coordinates.
The rightmost column (column 3) stores the translation vector. Element numbering is (row,column), so m03 is the row 0, column 3, which is the X translation.
Methods with names ending in "Local" modify the current instance. They are used to avoid creating garbage.
-
Field Summary
Modifier and TypeFieldDescriptionfloat
The element in row 0, column 0.float
The element in row 0, column 1.float
The element in row 0, column 2.float
The element in row 0, column 3 (the X translation).float
The element in row 1, column 0.float
The element in row 1, column 1.float
The element in row 1, column 2.float
The element in row 1, column 3 (the Y translation).float
The element in row 2, column 0.float
The element in row 2, column 1.float
The element in row 2, column 2.float
The element in row 2, column 3 (the Z translation).float
The element in row 3, column 0.float
The element in row 3, column 1.float
The element in row 3, column 2.float
The element in row 3, column 3. -
Constructor Summary
ConstructorDescriptionMatrix4f()
Instantiates an identity matrix (diagonals = 1, other elements = 0). -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a copy.boolean
Tests for exact equality with the argument, distinguishing -0 from 0.int
hashCode()
Returns a hash code.Inverts in place.void
Configures as an identity matrix (diagonals = 1, other elements = 0).void
multLocal
(float scalar) Multiplies in place by the scalar argument.void
setScale
(float x, float y, float z) Alters the scale component of the coordinate transform.void
Alters the scale component of the coordinate transform.void
setTranslation
(Vector3f translation) Alters the translation component of the coordinate transform.void
toRotationMatrix
(Matrix3f mat) Determines the rotation component of the coordinate transform.Returns the rotation component of the coordinate transform.toScaleVector
(Vector3f store) Determines the scale component of the coordinate transform.toString()
Returns a string representation of the matrix, which is unaffected.toTranslationVector
(Vector3f vector) Returns the translation component of the coordinate transform.zero()
Sets all elements to zero.
-
Field Details
-
m00
public float m00The element in row 0, column 0. -
m01
public float m01The element in row 0, column 1. -
m02
public float m02The element in row 0, column 2. -
m03
public float m03The element in row 0, column 3 (the X translation). -
m10
public float m10The element in row 1, column 0. -
m11
public float m11The element in row 1, column 1. -
m12
public float m12The element in row 1, column 2. -
m13
public float m13The element in row 1, column 3 (the Y translation). -
m20
public float m20The element in row 2, column 0. -
m21
public float m21The element in row 2, column 1. -
m22
public float m22The element in row 2, column 2. -
m23
public float m23The element in row 2, column 3 (the Z translation). -
m30
public float m30The element in row 3, column 0. -
m31
public float m31The element in row 3, column 1. -
m32
public float m32The element in row 3, column 2. -
m33
public float m33The element in row 3, column 3.
-
-
Constructor Details
-
Matrix4f
public Matrix4f()Instantiates an identity matrix (diagonals = 1, other elements = 0).
-
-
Method Details
-
loadIdentity
public void loadIdentity()Configures as an identity matrix (diagonals = 1, other elements = 0). -
multLocal
public void multLocal(float scalar) Multiplies in place by the scalar argument.- Parameters:
scalar
- the scaling factor to apply to all elements
-
invertLocal
Inverts in place. If the current instance is singular, the matrix is zeroed.- Returns:
- the (inverted) current instance (for chaining)
-
zero
Sets all elements to zero.- Returns:
- the (modified) current instance (for chaining)
-
toTranslationVector
Returns the translation component of the coordinate transform.- Parameters:
vector
- storage for the result (not null, modified)- Returns:
- the translation component (in
vector
) for chaining
-
toRotationQuat
Returns the rotation component of the coordinate transform.Assumes (but does not verify) that the transform consists entirely of translation, rotation, and positive scaling -- no reflection or shear.
- Parameters:
q
- storage for the result (not null, modified)- Returns:
- the rotation component (in
q
) for chaining
-
toRotationMatrix
Determines the rotation component of the coordinate transform.If the transform includes scaling or reflection or shear, the result might not be a valid rotation matrix.
- Parameters:
mat
- storage for the result (not null, modified)
-
toScaleVector
Determines the scale component of the coordinate transform.All components of the result will be non-negative, even if the coordinate transform includes reflection.
- Parameters:
store
- storage for the result (not null, modified)- Returns:
- the scale factors (in
store
) for chaining
-
setScale
public void setScale(float x, float y, float z) Alters the scale component of the coordinate transform.- Parameters:
x
- the desired scale factor for the X axisy
- the desired scale factor for the Y axisz
- the desired scale factor for the Z axis
-
setScale
Alters the scale component of the coordinate transform.- Parameters:
scale
- the desired scale factors (not null, unaffected)
-
setTranslation
Alters the translation component of the coordinate transform.- Parameters:
translation
- the desired translation (not null, unaffected)
-
toString
Returns a string representation of the matrix, which is unaffected. For example, the identity matrix is represented by:Matrix4f [ 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 ]
-
hashCode
public int hashCode()Returns a hash code. If two matrices have identical values, they will have the same hash code. The matrix is unaffected. -
equals
Tests for exact equality with the argument, distinguishing -0 from 0. Ifo
is null, false is returned. Either way, the current instance is unaffected. -
clone
Creates a copy. The current instance is unaffected.
-