public final class Matrix3f
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Element numbering is (row, column), so m01 is the element in row 0, column 1.
For pure rotations, the Quaternion class provides a
more efficient representation.
With one exception, the methods with names ending in "Local" modify the current instance. They are used to avoid creating garbage.
| Modifier and Type | Field and Description |
|---|---|
static Matrix3f |
IDENTITY
Shared instance of the identity matrix (diagonals = 1, other elements =
0).
|
protected float |
m00
The element in row 0, column 0.
|
protected float |
m01
The element in row 0, column 1.
|
protected float |
m02
The element in row 0, column 2.
|
protected float |
m10
The element in row 1, column 0.
|
protected float |
m11
The element in row 1, column 1.
|
protected float |
m12
The element in row 1, column 2.
|
protected float |
m20
The element in row 2, column 0.
|
protected float |
m21
The element in row 2, column 1.
|
protected float |
m22
The element in row 2, column 2.
|
static Matrix3f |
ZERO
Shared instance of the all-zero matrix.
|
| Constructor and Description |
|---|
Matrix3f()
Instantiates an identity matrix (diagonals = 1, other elements = 0).
|
Matrix3f(float m00,
float m01,
float m02,
float m10,
float m11,
float m12,
float m20,
float m21,
float m22)
Instantiates a matrix with specified elements.
|
| Modifier and Type | Method and Description |
|---|---|
Matrix3f |
clone()
Creates a copy.
|
float |
determinant()
Returns the determinant.
|
boolean |
equals(java.lang.Object o)
Tests for exact equality with the argument, distinguishing -0 from 0.
|
void |
fromAxes(Vector3f uAxis,
Vector3f vAxis,
Vector3f wAxis)
Configures from the specified column vectors.
|
float |
get(int i,
int j)
Returns the element at the specified position.
|
int |
hashCode()
Returns a hash code.
|
Matrix3f |
invert(Matrix3f store)
Returns the multiplicative inverse in the specified storage.
|
boolean |
isIdentity()
Tests for exact identity.
|
void |
loadIdentity()
Configures as an identity matrix (diagonals = 1, other elements = 0).
|
Matrix3f |
mult(Matrix3f mat,
Matrix3f product)
Multiplies with the specified matrix and returns the product in a 3rd
matrix.
|
Vector3f |
mult(Vector3f vec,
Vector3f product)
Applies the linear transformation to specified vector and stores the
result in another vector.
|
Matrix3f |
multLocal(float scale)
Multiplies by the scalar argument and returns the (modified) current
instance.
|
Matrix3f |
set(int i,
int j,
float value)
Sets the specified element.
|
Matrix3f |
set(Matrix3f matrix)
Copies the matrix argument.
|
Matrix3f |
set(Quaternion quaternion)
Configures as a rotation matrix equivalent to the argument.
|
java.lang.String |
toString()
Returns a string representation of the matrix, which is unaffected.
|
Matrix3f |
zero()
Sets all elements to zero.
|
protected float m00
protected float m01
protected float m02
protected float m10
protected float m11
protected float m12
protected float m20
protected float m21
protected float m22
public static final Matrix3f ZERO
public static final Matrix3f IDENTITY
public Matrix3f()
public Matrix3f(float m00,
float m01,
float m02,
float m10,
float m11,
float m12,
float m20,
float m21,
float m22)
m00 - the desired value for row 0, column 0m01 - the desired value for row 0, column 1m02 - the desired value for row 0, column 2m10 - the desired value for row 1, column 0m11 - the desired value for row 1, column 1m12 - the desired value for row 1, column 2m20 - the desired value for row 2, column 0m21 - the desired value for row 2, column 1m22 - the desired value for row 2, column 2public Matrix3f set(Matrix3f matrix)
matrix - the matrix to copy (unaffected) or null for identitypublic float get(int i,
int j)
i - the row index (0, 1, or 2)j - the column index (0, 1, or 2)java.lang.IllegalArgumentException - if either index isn't 0, 1, or 2public Matrix3f set(int i, int j, float value)
i - the row index (0, 1, or 2)j - the column index (0, 1, or 2)value - desired value for the element at (i, j)java.lang.IllegalArgumentException - if either index isn't 0, 1, or 2public void fromAxes(Vector3f uAxis, Vector3f vAxis, Vector3f wAxis)
uAxis - the desired value for column 0 (not null, unaffected)vAxis - the desired value for column 1 (not null, unaffected)wAxis - the desired value for column 2 (not null, unaffected)public Matrix3f set(Quaternion quaternion)
quaternion - the input quaternion (not null, unaffected)public void loadIdentity()
public boolean isIdentity()
public Matrix3f mult(Matrix3f mat, Matrix3f product)
product.
Note that matrix multiplication is noncommutative, so generally q * p != p * q.
It is safe for mat and product to be the same object.
mat - the right factor (not null, unaffected unless it's product)product - storage for the product, or null for a new Matrix3fthis times mat (either product or a new
Matrix3f)public Vector3f mult(Vector3f vec, Vector3f product)
This can also be described as multiplying the matrix by a column vector.
It is safe for vec and product to be the same object.
vec - the coordinates to transform (not null, unaffected unless it's
product)product - storage for the result, or null for a new Vector3fproduct or a new Vector3fpublic Matrix3f multLocal(float scale)
scale - the scaling factorpublic Matrix3f invert(Matrix3f store)
If this and store are the same object, the result is
undefined.
store - storage for the result, or null for a new Matrix3fstore or a new Matrix3fpublic float determinant()
public Matrix3f zero()
public java.lang.String toString()
Matrix3f [ 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 ]
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public boolean equals(java.lang.Object o)
o is null, false is returned. Either way, the current instance is
unaffected.equals in class java.lang.Objecto - the object to compare (may be null, unaffected)this and o have identical values,
otherwise falsepublic Matrix3f clone()
clone in class java.lang.Object