Class PMatrices3x3D
java.lang.Object
com.io7m.jtensors.core.parameterized.matrices.PMatrices3x3D
public final class PMatrices3x3D
extends java.lang.Object
Functions over PMatrix3x3D
values.
See "Mathematics for 3D Game Programming and Computer Graphics" 2nd Ed for the derivations of most of the code in this class (ISBN: 1-58450-277-0).
- Since:
- 8.0.0
-
Method Summary
Modifier and Type Method Description static <A, B, C, D, E, F>
PMatrix3x3D<E,F>add(PMatrix3x3D<A,B> m0, PMatrix3x3D<C,D> m1)
Add the matricesm0
andm1
.static <A, B> Vector3D
column0(PMatrix3x3D<A,B> m)
static <A, B> Vector3D
column1(PMatrix3x3D<A,B> m)
static <A, B> Vector3D
column2(PMatrix3x3D<A,B> m)
static <A, B> double
determinant(PMatrix3x3D<A,B> m)
Calculate the determinant of the matrixm
.static <A, B> PMatrix3x3D<A,B>
identity()
The identity matrix.static <A, B> java.util.Optional<PMatrix3x3D<B,A>>
invert(PMatrix3x3D<A,B> m)
Calculate the inverse of the matrixm
.static <A, B, C> PMatrix3x3D<A,C>
multiply(PMatrix3x3D<B,C> m0, PMatrix3x3D<A,B> m1)
Multiply the matricesm0
andm1
.static <A, B> PVector3D<B>
multiplyVectorPost(PMatrix3x3D<A,B> m, PVector3D<A> v)
Multiply the vectorv
by the matrixm
.static Vector3D
multiplyVectorPost(PMatrix3x3D m, Vector3D v)
Multiply the vectorv
by the matrixm
.static <A, B> PMatrix3x3D<A,B>
ofAxisAngle(double axis_x, double axis_y, double axis_z, double angle)
Construct a matrix that will rotate byangle
radians around the axis(x, y, z)
.static <A, B> PMatrix3x3D<A,B>
ofColumns(Vector3D c0, Vector3D c1, Vector3D c2)
Construct a matrix from the column vectors(c0, c1, c2)
.static <A, B> PMatrix3x3D<A,B>
ofRows(Vector3D r0, Vector3D r1, Vector3D r2)
Construct a matrix from the row vectors(r0, r1, r2)
.static <A, B> PMatrix3x3D<A,B>
ofScale(double x, double y, double z)
Construct a matrix that will scale by(x, y, z)
.static <A, B> Vector3D
row0(PMatrix3x3D<A,B> m)
static <A, B> Vector3D
row1(PMatrix3x3D<A,B> m)
static <A, B> Vector3D
row2(PMatrix3x3D<A,B> m)
static <A, B, C, D> PMatrix3x3D<C,D>
scale(PMatrix3x3D<A,B> m, double r)
Scale the matrixm
byr
.static <A, B, C, D, E, F>
PMatrix3x3D<E,F>subtract(PMatrix3x3D<A,B> m0, PMatrix3x3D<C,D> m1)
Subtract the matricesm0
andm1
.static <A, B> PMatrix3x3D<A,B>
toParameterized(Matrix3x3D m)
static <A, B> Matrix3x3D
toUnparameterized(PMatrix3x3D<A,B> m)
static <A, B> double
trace(PMatrix3x3D<A,B> m)
Return the trace of the matrixm
.static <A, B> PMatrix3x3D<A,B>
transpose(PMatrix3x3D<A,B> m)
Calculate the transpose of the matrixm
.static <A, B> PMatrix3x3D<A,B>
withColumn(PMatrix3x3D<A,B> m, int column, double r0, double r1, double r2)
Set the columncolumn
ofm
to(r0, r1, r2)
.static <A, B> PMatrix3x3D<A,B>
withRow(PMatrix3x3D<A,B> m, int row, double c0, double c1, double c2)
Set the rowrow
ofm
to(c0, c1, c2)
.static <A, B> PMatrix3x3D<A,B>
zero()
The zero matrix.
-
Method Details
-
add
public static <A, B, C, D, E, F> PMatrix3x3D<E,F> add(PMatrix3x3D<A,B> m0, PMatrix3x3D<C,D> m1)Add the matricesm0
andm1
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)C
- A phantom type parameter (possibly representing a source coordinate system)D
- A phantom type parameter (possibly representing a target coordinate system)E
- A phantom type parameter (possibly representing a source coordinate system)F
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m0
- The left matrixm1
- The right matrix- Returns:
m0 + m1
-
determinant
Calculate the determinant of the matrixm
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The matrix- Returns:
- The determinant of
m
-
invert
Calculate the inverse of the matrixm
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The matrix- Returns:
- The inverse of
m
, or nothing if no inverse exists
-
multiply
Multiply the matricesm0
andm1
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)C
- A phantom type parameter (possibly representing a source coordinate system)- Parameters:
m0
- The left matrixm1
- The right matrix- Returns:
m0 * m1
-
multiplyVectorPost
Multiply the vector
v
by the matrixm
.This is post multiplication.
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The matrixv
- The vector- Returns:
m * v
-
multiplyVectorPost
Multiply the vector
v
by the matrixm
.This is post multiplication.
- Parameters:
m
- The matrixv
- The vector- Returns:
m * v
-
ofColumns
Construct a matrix from the column vectors(c0, c1, c2)
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
c0
- The column 0c1
- The column 1c2
- The column 2- Returns:
- A constructed matrix
-
ofRows
Construct a matrix from the row vectors(r0, r1, r2)
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
r0
- The row 0r1
- The row 1r2
- The row 2- Returns:
- A constructed matrix
-
ofScale
Construct a matrix that will scale by(x, y, z)
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
x
- The X scaling valuey
- The Y scaling valuez
- The Z scaling value- Returns:
- A constructed matrix
-
ofAxisAngle
public static <A, B> PMatrix3x3D<A,B> ofAxisAngle(double axis_x, double axis_y, double axis_z, double angle)Construct a matrix that will rotate byangle
radians around the axis(x, y, z)
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
angle
- The angle in radiansaxis_x
- The X axis valueaxis_y
- The Y axis valueaxis_z
- The Z axis value- Returns:
- A constructed matrix
-
row0
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a source coordinate system)- Parameters:
m
- The matrix- Returns:
- Row 0 of the matrix
-
row1
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a source coordinate system)- Parameters:
m
- The matrix- Returns:
- Row 1 of the matrix
-
row2
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a source coordinate system)- Parameters:
m
- The matrix- Returns:
- Row 2 of the matrix
-
column0
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a source coordinate system)- Parameters:
m
- The matrix- Returns:
- Column 0 of the matrix
-
column1
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a source coordinate system)- Parameters:
m
- The matrix- Returns:
- Column 1 of the matrix
-
column2
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a source coordinate system)- Parameters:
m
- The matrix- Returns:
- Column 2 of the matrix
-
scale
Scale the matrixm
byr
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)C
- A phantom type parameter (possibly representing a source coordinate system)D
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The matrixr
- The scale factor- Returns:
m * r
-
subtract
public static <A, B, C, D, E, F> PMatrix3x3D<E,F> subtract(PMatrix3x3D<A,B> m0, PMatrix3x3D<C,D> m1)Subtract the matricesm0
andm1
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)C
- A phantom type parameter (possibly representing a source coordinate system)D
- A phantom type parameter (possibly representing a target coordinate system)E
- A phantom type parameter (possibly representing a source coordinate system)F
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m0
- The left matrixm1
- The right matrix- Returns:
m0 - m1
-
trace
Return the trace of the matrixm
. The trace is defined as the sum of the diagonal elements of the matrix.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The matrix- Returns:
- The trace of the matrix
-
transpose
Calculate the transpose of the matrixm
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The matrix- Returns:
- The transpose of
m
-
withColumn
public static <A, B> PMatrix3x3D<A,B> withColumn(PMatrix3x3D<A,B> m, int column, double r0, double r1, double r2)Set the columncolumn
ofm
to(r0, r1, r2)
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system) * @param r0 The value of row 0 in the column- Parameters:
m
- The matrixcolumn
- The column index in the range[0, 2]
r1
- The value of row 1 in the columnr2
- The value of row 2 in the column- Returns:
- A matrix with the given row
-
withRow
public static <A, B> PMatrix3x3D<A,B> withRow(PMatrix3x3D<A,B> m, int row, double c0, double c1, double c2)Set the rowrow
ofm
to(c0, c1, c2)
.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The matrixrow
- The row index in the range[0, 2]
c0
- The value of column 0 in the rowc1
- The value of column 1 in the rowc2
- The value of column 2 in the row- Returns:
- A matrix with the given row
-
zero
The zero matrix.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Returns:
- A matrix with all zero components
-
identity
The identity matrix.- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Returns:
- A matrix with all diagonal components set to 1 and all other components set to 0.
-
toUnparameterized
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The input matrix- Returns:
- A matrix equal to
m
but without type parameters
-
toParameterized
- Type Parameters:
A
- A phantom type parameter (possibly representing a source coordinate system)B
- A phantom type parameter (possibly representing a target coordinate system)- Parameters:
m
- The input matrix- Returns:
- A matrix equal to
m
with type parameters
-