public final class MatrixM2x2F extends Object
Functions over 2x2 mutable matrix types with float elements.
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).
See http://en.wikipedia.org/wiki/Row_equivalence#Elementary_row_operations for the three elementary operations defined on matrices.
| Modifier and Type | Class and Description |
|---|---|
static class |
MatrixM2x2F.ContextMM2F
The
ContextMM2F type contains the minimum storage required for
all of the functions of the MatrixM2x2F class. |
| Modifier and Type | Method and Description |
|---|---|
static <M extends MatrixWritable2x2FType> |
add(MatrixReadable2x2FType m0,
MatrixReadable2x2FType m1,
M out)
Elementwise add of matrices
m0 and m1. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
addInPlace(M m0,
MatrixReadable2x2FType m1)
Elementwise add of matrices
m0 and m1, returning the result
in m0. |
static <M extends MatrixWritable2x2FType> |
addRowScaled(MatrixM2x2F.ContextMM2F c,
MatrixReadable2x2FType m,
int row_a,
int row_b,
int row_c,
float r,
M out)
Add the values in row
row_b to the values in row row_a
scaled by r, saving the resulting row in row row_c of the
matrix out. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
addRowScaledInPlace(MatrixM2x2F.ContextMM2F c,
M m,
int row_a,
int row_b,
int row_c,
float r)
Add the values in row
row_b to the values in row row_a
scaled by r, saving the resulting row in row row_c of the
matrix m. |
static boolean |
compareElements(MatrixReadable2x2FType m0,
MatrixReadable2x2FType m1)
Compare matrices.
|
static <M extends MatrixWritable2x2FType> |
copy(MatrixReadable2x2FType input,
M output)
Copy the contents of the matrix
input to the matrix output,
completely replacing all elements. |
static float |
determinant(MatrixReadable2x2FType m)
Calculate the determinant of the matrix
m. |
static <M extends MatrixWritable2x2FType> |
exchangeRows(MatrixM2x2F.ContextMM2F c,
MatrixReadable2x2FType m,
int row_a,
int row_b,
M out)
Exchange two rows
row_a and row row_b of the matrix
m, saving the exchanged rows to out. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
exchangeRowsInPlace(MatrixM2x2F.ContextMM2F c,
M m,
int row_a,
int row_b)
Exchange two rows
row_a and row row_b of the matrix
m, saving the exchanged rows to m. |
static int |
hashElements(MatrixReadable2x2FType m)
Hash matrices.
|
static <M extends MatrixWritable2x2FType> |
invert(MatrixReadable2x2FType m,
M out)
Calculate the inverse of the matrix
m, saving the resulting matrix
to out. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
invertInPlace(M m)
Calculate the inverse of the matrix
m, saving the resulting matrix
to m. |
static <M extends MatrixWritable2x2FType> |
multiply(MatrixReadable2x2FType m0,
MatrixReadable2x2FType m1,
M out)
Multiply the matrix
m0 with the matrix m1, writing the
result to out. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
multiplyInPlace(M m0,
MatrixReadable2x2FType m1)
Multiply the matrix
m0 with the matrix m1, writing the
result to m0. |
static <V extends VectorWritable2FType> |
multiplyVector2F(MatrixM2x2F.ContextMM2F c,
MatrixReadable2x2FType m,
VectorReadable2FType v,
V out)
Multiply the matrix
m with the vector v, writing the
resulting vector to out. |
static <M extends MatrixWritable2x2FType> |
scale(MatrixReadable2x2FType m,
float r,
M out)
Scale all elements of the matrix
m by the scaling value r,
saving the result in out. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
scaleInPlace(M m,
float r)
Scale all elements of the matrix
m by the scaling value r,
saving the result in m. |
static <M extends MatrixWritable2x2FType> |
scaleRow(MatrixM2x2F.ContextMM2F c,
MatrixReadable2x2FType m,
int row,
float r,
M out)
Scale row
r of the matrix m by r, saving the
result to row r of out. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
scaleRowInPlace(MatrixM2x2F.ContextMM2F c,
M m,
int row,
float r)
Scale row
r of the matrix m by r, saving the
result to row r of m. |
static <M extends MatrixWritable2x2FType> |
setIdentity(M m)
Set the given matrix
m to the identity matrix. |
static <M extends MatrixWritable2x2FType> |
setZero(M m)
Set the given matrix
m to the zero matrix. |
static void |
showElements(MatrixReadable2x2FType m,
StringBuilder sb)
Show matrices.
|
static float |
trace(MatrixReadable2x2FType m)
Return the trace of the matrix
m. |
static <M extends MatrixWritable2x2FType> |
transpose(MatrixReadable2x2FType m,
M out)
Transpose the given matrix
m, writing the resulting matrix to
out. |
static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> |
transposeInPlace(M m)
Transpose the given matrix
m, writing the resulting matrix to
m. |
public static <M extends MatrixWritable2x2FType> M add(MatrixReadable2x2FType m0, MatrixReadable2x2FType m1, M out)
m0 and m1.M - The precise type of matrixm0 - The left input matrixm1 - The right input matrixout - The output matrixoutpublic static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> M addInPlace(M m0, MatrixReadable2x2FType m1)
m0 and m1, returning the result
in m0.M - The precise type of matrixm0 - The left input matrixm1 - The right input matrixm0public static <M extends MatrixWritable2x2FType> M addRowScaled(MatrixM2x2F.ContextMM2F c, MatrixReadable2x2FType m, int row_a, int row_b, int row_c, float r, M out)
Add the values in row row_b to the values in row row_a
scaled by r, saving the resulting row in row row_c of the
matrix out.
This is one of the three elementary operations defined on matrices.
M - The precise type of matrixc - Preallocated storagem - The input matrixrow_a - The row on the lefthand side of the additionrow_b - The row on the righthand side of the additionrow_c - The destination rowr - The scaling valueout - The output matrixoutpublic static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> M addRowScaledInPlace(MatrixM2x2F.ContextMM2F c, M m, int row_a, int row_b, int row_c, float r)
Add the values in row row_b to the values in row row_a
scaled by r, saving the resulting row in row row_c of the
matrix m.
This is one of the three elementary operations defined on matrices.
M - The precise type of matrixc - Preallocated storagem - The input matrixrow_a - The row on the lefthand side of the additionrow_b - The row on the righthand side of the additionrow_c - The destination rowr - The scaling valuempublic static <M extends MatrixWritable2x2FType> M copy(MatrixReadable2x2FType input, M output)
input to the matrix output,
completely replacing all elements.M - The precise type of matrixinput - The input vectoroutput - The output vectoroutputpublic static float determinant(MatrixReadable2x2FType m)
m.m - The input matrixpublic static <M extends MatrixWritable2x2FType> M exchangeRows(MatrixM2x2F.ContextMM2F c, MatrixReadable2x2FType m, int row_a, int row_b, M out)
Exchange two rows row_a and row row_b of the matrix
m, saving the exchanged rows to out.
This is one of the three elementary operations defined on matrices.
M - The precise type of matrixc - Preallocated storagem - The input matrixrow_a - The first rowrow_b - The second rowout - The output matrixoutpublic static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> M exchangeRowsInPlace(MatrixM2x2F.ContextMM2F c, M m, int row_a, int row_b)
Exchange two rows row_a and row row_b of the matrix
m, saving the exchanged rows to m.
This is one of the three elementary operations defined on matrices.
M - The precise type of matrixc - Preallocated storagem - The input matrixrow_a - The first rowrow_b - The second rowmpublic static <M extends MatrixWritable2x2FType> boolean invert(MatrixReadable2x2FType m, M out)
m, saving the resulting matrix
to out. The function returns Some(out) iff it was possible
to invert the matrix, and None otherwise. It is not possible to
invert a matrix that has a determinant of 0. If the function
returns None, m is untouched.M - The precise type of matrixm - The input matrixout - The output matrixtrue iff the matrix was invertibledeterminant(MatrixReadable2x2FType)public static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> boolean invertInPlace(M m)
m, saving the resulting matrix
to m. The function returns Some(m) iff it was possible to
invert the matrix, and None otherwise. It is not possible to invert
a matrix that has a determinant of 0. If the function returns
None, m is untouched.M - The precise type of matrixm - The input matrixtrue iff the matrix was invertibledeterminant(MatrixReadable2x2FType)public static <M extends MatrixWritable2x2FType> M multiply(MatrixReadable2x2FType m0, MatrixReadable2x2FType m1, M out)
m0 with the matrix m1, writing the
result to out.M - The precise type of matrixm0 - The left input matrixm1 - The right input matrixout - The output matrixoutpublic static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> M multiplyInPlace(M m0, MatrixReadable2x2FType m1)
m0 with the matrix m1, writing the
result to m0.M - The precise type of matrixm0 - The left input vectorm1 - The right input vectoroutpublic static <V extends VectorWritable2FType> V multiplyVector2F(MatrixM2x2F.ContextMM2F c, MatrixReadable2x2FType m, VectorReadable2FType v, V out)
m with the vector v, writing the
resulting vector to out.V - The precise type of writable vectorc - Preallocated storagem - The input matrixv - The input vectorout - The output vectoroutpublic static <M extends MatrixWritable2x2FType> M scale(MatrixReadable2x2FType m, float r, M out)
m by the scaling value r,
saving the result in out.M - The precise type of matrixm - The input matrixr - The scaling valueout - The output matrixoutpublic static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> M scaleInPlace(M m, float r)
m by the scaling value r,
saving the result in m.M - The precise type of matrixm - The input matrixr - The scaling valuempublic static <M extends MatrixWritable2x2FType> M scaleRow(MatrixM2x2F.ContextMM2F c, MatrixReadable2x2FType m, int row, float r, M out)
Scale row r of the matrix m by r, saving the
result to row r of out.
This is one of the three elementary operations defined on matrices.
M - The precise type of matrixc - Preallocated storagem - The input matrixrow - The index of the row (0 <= row < 2)r - The scaling valueout - The output matrixoutpublic static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> M scaleRowInPlace(MatrixM2x2F.ContextMM2F c, M m, int row, float r)
Scale row r of the matrix m by r, saving the
result to row r of m.
This is one of the three elementary operations defined on matrices.
M - The precise type of matrixc - Preallocated storagem - The input matrixrow - The index of the row (0 <= row < 2)r - The scaling valuempublic static <M extends MatrixWritable2x2FType> M setIdentity(M m)
m to the identity matrix.M - The precise type of matrixm - The matrixmpublic static <M extends MatrixWritable2x2FType> M setZero(M m)
m to the zero matrix.M - The precise type of matrixm - The matrixmpublic static float trace(MatrixReadable2x2FType m)
m. The trace is defined as the sum
of the diagonal elements of the matrix.m - The input matrixpublic static <M extends MatrixWritable2x2FType> M transpose(MatrixReadable2x2FType m, M out)
m, writing the resulting matrix to
out.M - The precise type of matrixm - The input matrixout - The output matrixoutpublic static <M extends MatrixWritable2x2FType & MatrixReadable2x2FType> M transposeInPlace(M m)
m, writing the resulting matrix to
m.M - The precise type of matrixm - The input matrixmpublic static boolean compareElements(MatrixReadable2x2FType m0, MatrixReadable2x2FType m1)
m0 - The left matrixm1 - The right matrixtrue if all elements of m0 are equal to m1.public static int hashElements(MatrixReadable2x2FType m)
m - The input matrixmpublic static void showElements(MatrixReadable2x2FType m, StringBuilder sb)
m in square-bracketed
matrix form.m - The input matrixsb - The string builderCopyright © 2015 <code@io7m.com> http://io7m.com