public final class Matrix44F
extends java.lang.Object
Matrix44F
denotes a matrix with four columns and four rows that is stored in row-major order.
This class is immutable and therefore thread-safe.
Modifier and Type | Field and Description |
---|---|
float |
element00
The element at index
0 or row 0 and column 0 . |
float |
element01
The element at index
1 or row 0 and column 1 . |
float |
element02
The element at index
2 or row 0 and column 2 . |
float |
element03
The element at index
3 or row 0 and column 3 . |
float |
element10
The element at index
4 or row 1 and column 0 . |
float |
element11
The element at index
5 or row 1 and column 1 . |
float |
element12
The element at index
6 or row 1 and column 2 . |
float |
element13
The element at index
7 or row 1 and column 3 . |
float |
element20
The element at index
8 or row 2 and column 0 . |
float |
element21
The element at index
9 or row 2 and column 1 . |
float |
element22
The element at index
10 or row 2 and column 2 . |
float |
element23
The element at index
11 or row 2 and column 3 . |
float |
element30
The element at index
12 or row 3 and column 0 . |
float |
element31
The element at index
13 or row 3 and column 1 . |
float |
element32
The element at index
14 or row 3 and column 2 . |
float |
element33
The element at index
15 or row 3 and column 3 . |
Constructor and Description |
---|
Matrix44F()
Constructs a new
Matrix44F instance representing the identity matrix. |
Matrix44F(float[] elements)
Constructs a new
Matrix44F instance given its element values. |
Matrix44F(float[][] elements)
Constructs a new
Matrix44F instance given its element values. |
Matrix44F(float element00,
float element01,
float element02,
float element03,
float element10,
float element11,
float element12,
float element13,
float element20,
float element21,
float element22,
float element23,
float element30,
float element31,
float element32,
float element33)
Constructs a new
Matrix44F instance given its element values. |
Modifier and Type | Method and Description |
---|---|
float |
determinant()
Returns the determinant of this
Matrix44F instance. |
boolean |
equals(java.lang.Object object)
Compares
object to this Matrix44F instance for equality. |
static Matrix44F |
fromOrthoNormalBasis(OrthoNormalBasis33F orthoNormalBasis)
Returns a new
Matrix44F from an OrthoNormalBasis33F . |
float |
getElement00()
Returns the element at index
0 or row 0 and column 0 . |
float |
getElement01()
Returns the element at index
1 or row 0 and column 1 . |
float |
getElement02()
Returns the element at index
2 or row 0 and column 2 . |
float |
getElement03()
Returns the element at index
3 or row 0 and column 3 . |
float |
getElement10()
Returns the element at index
4 or row 1 and column 0 . |
float |
getElement11()
Returns the element at index
5 or row 1 and column 1 . |
float |
getElement12()
Returns the element at index
6 or row 1 and column 2 . |
float |
getElement13()
Returns the element at index
7 or row 1 and column 3 . |
float |
getElement20()
Returns the element at index
8 or row 2 and column 0 . |
float |
getElement21()
Returns the element at index
9 or row 2 and column 1 . |
float |
getElement22()
Returns the element at index
10 or row 2 and column 2 . |
float |
getElement23()
Returns the element at index
11 or row 2 and column 3 . |
float |
getElement30()
Returns the element at index
12 or row 3 and column 0 . |
float |
getElement31()
Returns the element at index
13 or row 3 and column 1 . |
float |
getElement32()
Returns the element at index
14 or row 3 and column 2 . |
float |
getElement33()
Returns the element at index
15 or row 3 and column 3 . |
int |
hashCode()
Returns a hash code for this
Matrix44F instance. |
Matrix44F |
inverse()
Returns a new
Matrix44F that represents the inverse of this Matrix44F instance. |
boolean |
isIdentity()
Returns
true if, and only if, this Matrix44F represents the identity matrix, false otherwise. |
Matrix44F |
multiply(Matrix44F matrix)
Multiplies this
Matrix44F instance by matrix . |
static Matrix44F |
perspective(AngleF fieldOfView,
float aspectRatio,
float zNear,
float zFar)
Returns a
Matrix44F for perspective viewing. |
static Matrix44F |
rotate(Vector3F w,
Vector3F v)
Returns a
Matrix44F for rotating along the X-, Y- and Z-axes. |
static Matrix44F |
rotate(Vector3F w,
Vector3F v,
Vector3F u)
Returns a
Matrix44F for rotating along the X-, Y- and Z-axes. |
static Matrix44F |
rotateX(AngleF angle)
Returns a
Matrix44F for rotating along the X-axis. |
static Matrix44F |
rotateY(AngleF angle)
Returns a
Matrix44F for rotating along the Y-axis. |
static Matrix44F |
rotateZ(AngleF angle)
Returns a
Matrix44F for rotating along the Z-axis. |
static Matrix44F |
scale(float x,
float y,
float z)
Returns a
Matrix44F for scaling. |
float[] |
toArray1D()
Returns this
Matrix44F as a one-dimensional float array in row-major order. |
float[][] |
toArray2D()
Returns this
Matrix44F as a two-dimensional float array in row-major order. |
java.lang.String |
toString()
Returns a
String representation of this Matrix44F instance. |
static Matrix44F |
translate(float x,
float y,
float z)
Returns a
Matrix44F for translation. |
static Matrix44F |
translate(Point3F p)
Returns a
Matrix44F for translation. |
Matrix44F |
transpose()
Returns a new
Matrix44F that represents the transpose of this Matrix44F instance. |
public final float element00
0
or row 0
and column 0
.public final float element01
1
or row 0
and column 1
.public final float element02
2
or row 0
and column 2
.public final float element03
3
or row 0
and column 3
.public final float element10
4
or row 1
and column 0
.public final float element11
5
or row 1
and column 1
.public final float element12
6
or row 1
and column 2
.public final float element13
7
or row 1
and column 3
.public final float element20
8
or row 2
and column 0
.public final float element21
9
or row 2
and column 1
.public final float element22
10
or row 2
and column 2
.public final float element23
11
or row 2
and column 3
.public final float element30
12
or row 3
and column 0
.public final float element31
13
or row 3
and column 1
.public final float element32
14
or row 3
and column 2
.public final float element33
15
or row 3
and column 3
.public Matrix44F()
Matrix44F
instance representing the identity matrix.
Calling this constructor is equivalent to the following:
new Matrix44F(1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F)
public Matrix44F(float element00, float element01, float element02, float element03, float element10, float element11, float element12, float element13, float element20, float element21, float element22, float element23, float element30, float element31, float element32, float element33)
Matrix44F
instance given its element values.element00
- the element at index 0
or row 0
and column 0
element01
- the element at index 1
or row 0
and column 1
element02
- the element at index 2
or row 0
and column 2
element03
- the element at index 3
or row 0
and column 3
element10
- the element at index 4
or row 1
and column 0
element11
- the element at index 5
or row 1
and column 1
element12
- the element at index 6
or row 1
and column 2
element13
- the element at index 7
or row 1
and column 3
element20
- the element at index 8
or row 2
and column 0
element21
- the element at index 9
or row 2
and column 1
element22
- the element at index 10
or row 2
and column 2
element23
- the element at index 11
or row 2
and column 3
element30
- the element at index 12
or row 3
and column 0
element31
- the element at index 13
or row 3
and column 1
element32
- the element at index 14
or row 3
and column 2
element33
- the element at index 15
or row 3
and column 3
public Matrix44F(float[] elements)
Matrix44F
instance given its element values.
Calling this constructor is equivalent to the following (assuming elements
is called e
for brevity):
new Matrix44F(e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9], e[10], e[11], e[12], e[13], e[14], e[15])
If elements
is null
, a NullPointerException
will be thrown.
If elements.length
is less than 16
, an ArrayIndexOutOfBoundsException
will be thrown.
elements
- a one-dimensional float
array with the element values to usejava.lang.ArrayIndexOutOfBoundsException
- thrown if, and only if, elements.length
is less than 16
java.lang.NullPointerException
- thrown if, and only if, elements
is null
public Matrix44F(float[][] elements)
Matrix44F
instance given its element values.
Calling this constructor is equivalent to the following (assuming elements
is called e
for brevity):
new Matrix44F(e[0][0], e[0][1], e[0][2], e[0][3], e[1][0], e[1][1], e[1][2], e[1][3], e[2][0], e[2][1], e[2][2], e[2][3], e[3][0], e[3][1], e[3][2], e[3][3])
If either elements
or its elements are null
, a NullPointerException
will be thrown.
If elements.length
is less than 4
or elements[i].length
is less than 4
, where 0 <= i < 4
, an ArrayIndexOutOfBoundsException
will be thrown.
elements
- a two-dimensional float
array with the element values to usejava.lang.ArrayIndexOutOfBoundsException
- thrown if, and only if, elements.length
is less than 4
or elements[i].length
is less than 4
, where 0 <= i < 4
java.lang.NullPointerException
- thrown if, and only if, either elements
or its elements are null
public Matrix44F inverse()
Matrix44F
that represents the inverse of this Matrix44F
instance.
If this Matrix44F
cannot be inverted, an IllegalStateException
will be thrown.
Matrix44F
that represents the inverse of this Matrix44F
instancejava.lang.IllegalStateException
- thrown if, and only if, this Matrix44F
cannot be invertedpublic Matrix44F multiply(Matrix44F matrix)
Matrix44F
instance by matrix
.
Returns a new Matrix44F
instance with the result of the multiplication.
If matrix
is null
, a NullPointerException
will be thrown.
matrix
- the Matrix44F
to multiply this Matrix44F
instance withMatrix44F
instance with the result of the multiplicationjava.lang.NullPointerException
- thrown if, and only if, matrix
is null
public Matrix44F transpose()
Matrix44F
that represents the transpose of this Matrix44F
instance.Matrix44F
that represents the transpose of this Matrix44F
instancepublic java.lang.String toString()
String
representation of this Matrix44F
instance.toString
in class java.lang.Object
String
representation of this Matrix44F
instancepublic boolean equals(java.lang.Object object)
object
to this Matrix44F
instance for equality.
Returns true
if, and only if, object
is an instance of Matrix44F
, and their respective values are equal, false
otherwise.
equals
in class java.lang.Object
object
- the Object
to compare to this Matrix44F
instance for equalitytrue
if, and only if, object
is an instance of Matrix44F
, and their respective values are equal, false
otherwisepublic boolean isIdentity()
true
if, and only if, this Matrix44F
represents the identity matrix, false
otherwise.true
if, and only if, this Matrix44F
represents the identity matrix, false
otherwisepublic float determinant()
Matrix44F
instance.Matrix44F
instancepublic float getElement00()
0
or row 0
and column 0
.0
or row 0
and column 0
public float getElement01()
1
or row 0
and column 1
.1
or row 0
and column 1
public float getElement02()
2
or row 0
and column 2
.2
or row 0
and column 2
public float getElement03()
3
or row 0
and column 3
.3
or row 0
and column 3
public float getElement10()
4
or row 1
and column 0
.4
or row 1
and column 0
public float getElement11()
5
or row 1
and column 1
.5
or row 1
and column 1
public float getElement12()
6
or row 1
and column 2
.6
or row 1
and column 2
public float getElement13()
7
or row 1
and column 3
.7
or row 1
and column 3
public float getElement20()
8
or row 2
and column 0
.8
or row 2
and column 0
public float getElement21()
9
or row 2
and column 1
.9
or row 2
and column 1
public float getElement22()
10
or row 2
and column 2
.10
or row 2
and column 2
public float getElement23()
11
or row 2
and column 3
.11
or row 2
and column 3
public float getElement30()
12
or row 3
and column 0
.12
or row 3
and column 0
public float getElement31()
13
or row 3
and column 1
.13
or row 3
and column 1
public float getElement32()
14
or row 3
and column 2
.14
or row 3
and column 2
public float getElement33()
15
or row 3
and column 3
.15
or row 3
and column 3
public float[] toArray1D()
Matrix44F
as a one-dimensional float
array in row-major order.Matrix44F
as a one-dimensional float
array in row-major orderpublic float[][] toArray2D()
Matrix44F
as a two-dimensional float
array in row-major order.Matrix44F
as a two-dimensional float
array in row-major orderpublic int hashCode()
Matrix44F
instance.hashCode
in class java.lang.Object
Matrix44F
instancepublic static Matrix44F fromOrthoNormalBasis(OrthoNormalBasis33F orthoNormalBasis)
Matrix44F
from an OrthoNormalBasis33F
.
If orthoNormalBasis
is null
, a NullPointerException
will be thrown.
The layout looks like this:
u.x, v.x, w.x, 0
u.y, v.y, w.y, 0
u.z, v.z, w.z, 0
0, 0, 0, 1
orthoNormalBasis
- an OrthoNormalBasis33F
Matrix44F
from an OrthoNormalBasis33F
java.lang.NullPointerException
- thrown if, and only if, orthoNormalBasis
is null
public static Matrix44F perspective(AngleF fieldOfView, float aspectRatio, float zNear, float zFar)
Matrix44F
for perspective viewing.
If fieldOfView
is null
, a NullPointerException
will be thrown.
fieldOfView
- an AngleF
with field of viewaspectRatio
- the aspect ratio to usezNear
- the Z-near to usezFar
- the Z-far to useMatrix44F
for perspective viewingjava.lang.NullPointerException
- thrown if, and only if, fieldOfView
is null
public static Matrix44F rotate(Vector3F w, Vector3F v)
Matrix44F
for rotating along the X-, Y- and Z-axes.
If either w
or v
are null
, a NullPointerException
will be thrown.
The layout looks like this:
u.x, u.y, u.z, 0
v.x, v.y, v.z, 0
w.x, w.y, w.z, 0
0, 0, 0, 1
Note that the layout above does not use the w
and v
Vector3F
s supplied as arguments to this method directly. They are only used as a starting point for the construction of the OrthoNormal Basis (ONB).w
- a Vector3F
v
- a Vector3F
Matrix44F
for rotating along the X-, Y- and Z-axesjava.lang.NullPointerException
- thrown if, and only if, either w
or v
are null
public static Matrix44F rotate(Vector3F w, Vector3F v, Vector3F u)
Matrix44F
for rotating along the X-, Y- and Z-axes.
If either w
, v
or u
are null
, a NullPointerException
will be thrown.
The layout looks like this:
u.x, u.y, u.z, 0
v.x, v.y, v.z, 0
w.x, w.y, w.z, 0
0, 0, 0, 1
w
- a Vector3F
v
- a Vector3F
u
- a Vector3F
Matrix44F
for rotating along the X-, Y- and Z-axesjava.lang.NullPointerException
- thrown if, and only if, either w
, v
or u
are null
public static Matrix44F rotateX(AngleF angle)
Matrix44F
for rotating along the X-axis.
If angle
is null
, a NullPointerException
will be thrown.
The layout looks like this:
1, 0, 0, 0
0, +cos, -sin, 0
0, +sin, +cos, 0
0, 0, 0, 1
angle
- an AngleF
Matrix44F
for rotating along the X-axisjava.lang.NullPointerException
- thrown if, and only if, angle
is null
public static Matrix44F rotateY(AngleF angle)
Matrix44F
for rotating along the Y-axis.
If angle
is null
, a NullPointerException
will be thrown.
The layout looks like this:
+cos, 0, +sin, 0
0, 1, 0, 0
-sin, 0, +cos, 0
0, 0, 0, 1
angle
- an AngleF
Matrix44F
for rotating along the Y-axisjava.lang.NullPointerException
- thrown if, and only if, angle
is null
public static Matrix44F rotateZ(AngleF angle)
Matrix44F
for rotating along the Z-axis.
If angle
is null
, a NullPointerException
will be thrown.
The layout looks like this:
+cos, -sin, 0, 0
+sin, +cos, 0, 0
0, 0, 1, 0
0, 0, 0, 1
angle
- an AngleF
Matrix44F
for rotating along the Z-axisjava.lang.NullPointerException
- thrown if, and only if, angle
is null
public static Matrix44F scale(float x, float y, float z)
Matrix44F
for scaling.
The layout looks like this:
x, 0, 0, 0
0, y, 0, 0
0, 0, z, 0
0, 0, 0, 1
x
- the scale factor along the X-axisy
- the scale factor along the Y-axisz
- the scale factor along the Z-axisMatrix44F
for scalingpublic static Matrix44F translate(Point3F p)
Matrix44F
for translation.
If p
is null
, a NullPointerException
will be thrown.
The layout looks like this:
1, 0, 0, p.x
0, 1, 0, p.y
0, 0, 1, p.z
0, 0, 0, 1
p
- a Point3F
Matrix44F
for translationjava.lang.NullPointerException
- thrown if, and only if, p
is null
public static Matrix44F translate(float x, float y, float z)
Matrix44F
for translation.
The layout looks like this:
1, 0, 0, x
0, 1, 0, y
0, 0, 1, z
0, 0, 0, 1
x
- the translation factor along the X-axisy
- the translation factor along the Y-axisz
- the translation factor along the Z-axisMatrix44F
for translation