Class PMatrices2x2F
java.lang.Object
com.io7m.jtensors.core.parameterized.matrices.PMatrices2x2F
public final class PMatrices2x2F
extends java.lang.Object
Functions over PMatrix2x2F 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>
PMatrix2x2F<E,F>add(PMatrix2x2F<A,B> m0, PMatrix2x2F<C,D> m1)Add the matricesm0andm1.static <A, B> Vector2Fcolumn0(PMatrix2x2F<A,B> m)static <A, B> Vector2Fcolumn1(PMatrix2x2F<A,B> m)static <A, B> doubledeterminant(PMatrix2x2F<A,B> m)Calculate the determinant of the matrixm.static <A, B> PMatrix2x2F<A,B>identity()The identity matrix.static <A, B> java.util.Optional<PMatrix2x2F<B,A>>invert(PMatrix2x2F<A,B> m)Calculate the inverse of the matrixm.static <A, B, C> PMatrix2x2F<A,C>multiply(PMatrix2x2F<B,C> m0, PMatrix2x2F<A,B> m1)Multiply the matricesm0andm1.static <A, B> PVector2F<B>multiplyVectorPost(PMatrix2x2F<A,B> m, PVector2F<A> v)Multiply the vectorvby the matrixm.static Vector2FmultiplyVectorPost(PMatrix2x2F m, Vector2F v)Multiply the vectorvby the matrixm.static <A, B> PMatrix2x2F<A,B>ofColumns(Vector2F c0, Vector2F c1)Construct a matrix from the column vectors(c0, c1).static <A, B> PMatrix2x2F<A,B>ofRows(Vector2F r0, Vector2F r1)Construct a matrix from the row vectors(r0, r1).static <A, B> PMatrix2x2F<A,B>ofScale(double x, double y)Construct a matrix that will scale by(x, y).static <A, B> Vector2Frow0(PMatrix2x2F<A,B> m)static <A, B> Vector2Frow1(PMatrix2x2F<A,B> m)static <A, B, C, D> PMatrix2x2F<C,D>scale(PMatrix2x2F<A,B> m, double r)Scale the matrixmbyr.static <A, B, C, D, E, F>
PMatrix2x2F<E,F>subtract(PMatrix2x2F<A,B> m0, PMatrix2x2F<C,D> m1)Subtract the matricesm0andm1.static <A, B> PMatrix2x2F<A,B>toParameterized(Matrix2x2F m)static <A, B> Matrix2x2FtoUnparameterized(PMatrix2x2F<A,B> m)static <A, B> doubletrace(PMatrix2x2F<A,B> m)Return the trace of the matrixm.static <A, B> PMatrix2x2F<A,B>transpose(PMatrix2x2F<A,B> m)Calculate the transpose of the matrixm.static <A, B> PMatrix2x2F<A,B>withColumn(PMatrix2x2F<A,B> m, int column, float r0, float r1)Set the columncolumnofmto(r0, r1).static <A, B> PMatrix2x2F<A,B>withRow(PMatrix2x2F<A,B> m, int row, float c0, float c1)Set the rowrowofmto(c0, c1).static <A, B> PMatrix2x2F<A,B>zero()The zero matrix.
-
Method Details
-
add
public static <A, B, C, D, E, F> PMatrix2x2F<E,F> add(PMatrix2x2F<A,B> m0, PMatrix2x2F<C,D> m1)Add the matricesm0andm1.- 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 matricesm0andm1.- 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
vby 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
vby 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).- 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 1- Returns:
- A constructed matrix
-
ofRows
Construct a matrix from the row vectors(r0, r1).- 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 1- Returns:
- A constructed matrix
-
ofScale
Construct a matrix that will scale by(x, y).- 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 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
-
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
-
scale
Scale the matrixmbyr.- 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> PMatrix2x2F<E,F> subtract(PMatrix2x2F<A,B> m0, PMatrix2x2F<C,D> m1)Subtract the matricesm0andm1.- 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> PMatrix2x2F<A,B> withColumn(PMatrix2x2F<A,B> m, int column, float r0, float r1)Set the columncolumnofmto(r0, r1).- 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, 1]r1- The value of row 1 in the column- Returns:
- A matrix with the given row
-
withRow
Set the rowrowofmto(c0, c1).- 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, 1]c0- The value of column 0 in the rowc1- The value of column 1 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
mbut 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
mwith type parameters
-