public class MatrixM2x2F extends Object implements MatrixReadable2x2FType
A 2x2 mutable matrix type with single precision elements.
Values of type MatrixM2x2F are backed by direct memory, with
the rows and columns of the matrices being stored in column-major format.
This allows the matrices to be passed to OpenGL directly, without requiring
transposition.
Values of this type cannot be accessed safely from multiple threads without explicit synchronization.
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).
| Constructor and Description |
|---|
MatrixM2x2F()
Construct a new identity matrix.
|
MatrixM2x2F(MatrixReadable2x2FType source)
Construct a new matrix from the given source matrix.
|
| Modifier and Type | Method and Description |
|---|---|
static MatrixM2x2F |
add(MatrixReadable2x2FType m0,
MatrixReadable2x2FType m1,
MatrixM2x2F out)
Elementwise add of matrices
m0 and m1. |
static MatrixM2x2F |
addInPlace(MatrixM2x2F m0,
MatrixReadable2x2FType m1)
Elementwise add of matrices
m0 and m1,
returning the result in m0. |
static MatrixM2x2F |
addRowScaled(MatrixReadable2x2FType m,
int row_a,
int row_b,
int row_c,
float r,
MatrixM2x2F 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 MatrixM2x2F |
addRowScaledInPlace(MatrixM2x2F 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 MatrixM2x2F |
copy(MatrixReadable2x2FType input,
MatrixM2x2F 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. |
boolean |
equals(Object obj) |
static MatrixM2x2F |
exchangeRows(MatrixReadable2x2FType m,
int row_a,
int row_b,
MatrixM2x2F out)
Exchange two rows
row_a and row row_b of the
matrix m, saving the exchanged rows to out. |
static MatrixM2x2F |
exchangeRowsInPlace(MatrixM2x2F 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 FloatBuffer |
floatBuffer(MatrixM2x2F m) |
float |
get(int row,
int column) |
static float |
get(MatrixReadable2x2FType m,
int row,
int column) |
FloatBuffer |
getFloatBuffer() |
void |
getRow2F(int row,
VectorM2F out)
Retrieve row
row, saving the result to out. |
float |
getRowColumnF(int row,
int column) |
int |
hashCode() |
static com.io7m.jfunctional.OptionType<MatrixM2x2F> |
invert(MatrixReadable2x2FType m,
MatrixM2x2F out)
Calculate the inverse of the matrix
m, saving the resulting
matrix to out. |
static com.io7m.jfunctional.OptionType<MatrixM2x2F> |
invertInPlace(MatrixM2x2F m)
Calculate the inverse of the matrix
m, saving the resulting
matrix to m. |
static MatrixM2x2F |
multiply(MatrixM2x2F m0,
MatrixReadable2x2FType m1)
Multiply the matrix
m0 with the matrix m1,
writing the result to m0. |
static MatrixM2x2F |
multiply(MatrixReadable2x2FType m0,
MatrixReadable2x2FType m1,
MatrixM2x2F out)
Multiply the matrix
m0 with the matrix m1,
writing the result to out. |
static VectorM2F |
multiplyVector2F(MatrixReadable2x2FType m,
VectorReadable2FType v,
VectorM2F out)
Multiply the matrix
m with the vector v,
writing the resulting vector to out. |
static VectorM2F |
row(MatrixReadable2x2FType m,
int row,
VectorM2F out) |
static MatrixM2x2F |
scale(MatrixM2x2F m,
float r)
Scale all elements of the matrix
m by the scaling value
r, saving the result in m. |
static MatrixM2x2F |
scale(MatrixReadable2x2FType m,
float r,
MatrixM2x2F out)
Scale all elements of the matrix
m by the scaling value
r, saving the result in out. |
static MatrixM2x2F |
scaleRow(MatrixM2x2F m,
int row,
float r)
Scale row
r of the matrix m by r,
saving the result to row r of m. |
static MatrixM2x2F |
scaleRow(MatrixReadable2x2FType m,
int row,
float r,
MatrixM2x2F out)
Scale row
r of the matrix m by r,
saving the result to row r of out. |
MatrixM2x2F |
set(int row,
int column,
float value) |
static MatrixM2x2F |
set(MatrixM2x2F m,
int row,
int column,
float value)
Set the value in the matrix
m at row row,
column column to value. |
static MatrixM2x2F |
setIdentity(MatrixM2x2F m)
Set the given matrix
m to the identity matrix. |
static MatrixM2x2F |
setZero(MatrixM2x2F m)
Set the given matrix
m to the zero matrix. |
String |
toString() |
static float |
trace(MatrixReadable2x2FType m)
Return the trace of the matrix
m. |
static MatrixM2x2F |
transpose(MatrixM2x2F m)
Transpose the given matrix
m, writing the resulting matrix
to m. |
static MatrixM2x2F |
transpose(MatrixReadable2x2FType m,
MatrixM2x2F out)
Transpose the given matrix
m, writing the resulting matrix
to out. |
public MatrixM2x2F()
public MatrixM2x2F(MatrixReadable2x2FType source)
source - The source matrixpublic static final MatrixM2x2F add(MatrixReadable2x2FType m0, MatrixReadable2x2FType m1, MatrixM2x2F out)
m0 and m1.m0 - The left input matrix.m1 - The right input matrix.out - The output matrix.outpublic static final MatrixM2x2F addInPlace(MatrixM2x2F m0, MatrixReadable2x2FType m1)
m0 and m1,
returning the result in m0.m0 - The left input matrix.m1 - The right input matrix.m0public static final MatrixM2x2F addRowScaled(MatrixReadable2x2FType m, int row_a, int row_b, int row_c, float r, MatrixM2x2F 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. See Elementary operations .
m - The input matrix.row_a - The row on the lefthand side of the addition.row_b - The row on the righthand side of the addition.row_c - The destination row.r - The scaling value.out - The output matrix.outpublic static final MatrixM2x2F addRowScaledInPlace(MatrixM2x2F 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. See Elementary operations .
m - The input matrix.row_a - The row on the lefthand side of the addition.row_b - The row on the righthand side of the addition.row_c - The destination row.r - The scaling value.mpublic static final MatrixM2x2F copy(MatrixReadable2x2FType input, MatrixM2x2F output)
input to the matrix
output, completely replacing all elements.input - The input vector.output - The output vector.outputpublic static final float determinant(MatrixReadable2x2FType m)
m.m - The input matrix.public static final MatrixM2x2F exchangeRows(MatrixReadable2x2FType m, int row_a, int row_b, MatrixM2x2F 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. See Elementary operations .
m - The input matrix.row_a - The first row.row_b - The second row.out - The output matrix.outpublic static final MatrixM2x2F exchangeRowsInPlace(MatrixM2x2F 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. See Elementary operations .
m - The input matrix.row_a - The first row.row_b - The second row.mpublic static final FloatBuffer floatBuffer(MatrixM2x2F m)
m - The input matrix.public static final float get(MatrixReadable2x2FType m, int row, int column)
row - The rowcolumn - The columnm - The matrixm at row row,
column column.public static final com.io7m.jfunctional.OptionType<MatrixM2x2F> invert(MatrixReadable2x2FType m, MatrixM2x2F 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 input matrix.out - The output matrix.outdeterminant(MatrixReadable2x2FType)public static final com.io7m.jfunctional.OptionType<MatrixM2x2F> invertInPlace(MatrixM2x2F 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 input matrix.mdeterminant(MatrixReadable2x2FType)public static final MatrixM2x2F multiply(MatrixM2x2F m0, MatrixReadable2x2FType m1)
m0 with the matrix m1,
writing the result to m0.m0 - The left input vector.m1 - The right input vector.outpublic static final MatrixM2x2F multiply(MatrixReadable2x2FType m0, MatrixReadable2x2FType m1, MatrixM2x2F out)
m0 with the matrix m1,
writing the result to out.m0 - The left input matrix.m1 - The right input matrix.out - The output matrix.outpublic static final VectorM2F multiplyVector2F(MatrixReadable2x2FType m, VectorReadable2FType v, VectorM2F out)
m with the vector v,
writing the resulting vector to out.m - The input matrix.v - The input vector.out - The output vector.outpublic static final VectorM2F row(MatrixReadable2x2FType m, int row, VectorM2F out)
m - The matrixrow - The rowout - The output vectorrow of the matrix m in the vector
out.public static final MatrixM2x2F scale(MatrixM2x2F m, float r)
m by the scaling value
r, saving the result in m.m - The input matrix.r - The scaling value.mpublic static final MatrixM2x2F scale(MatrixReadable2x2FType m, float r, MatrixM2x2F out)
m by the scaling value
r, saving the result in out.m - The input matrix.r - The scaling value.out - The output matrix.outpublic static final MatrixM2x2F scaleRow(MatrixM2x2F 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. See Elementary operations .
m - The input matrix.row - The index of the row (0 <= row < 4).r - The scaling value.mpublic static final MatrixM2x2F scaleRow(MatrixReadable2x2FType m, int row, float r, MatrixM2x2F 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. See Elementary operations .
m - The input matrix.row - The index of the row (0 <= row < 4).r - The scaling value.out - The output matrix.outpublic static final MatrixM2x2F set(MatrixM2x2F m, int row, int column, float value)
m at row row,
column column to value.m - The matrixrow - The rowcolumn - The columnvalue - The valuempublic static final MatrixM2x2F setIdentity(MatrixM2x2F m)
m to the identity matrix.m - The matrixmpublic static final MatrixM2x2F setZero(MatrixM2x2F m)
m to the zero matrix.m - The matrixmpublic static final float trace(MatrixReadable2x2FType m)
m. The trace is defined as
the sum of the diagonal elements of the matrix.m - The input matrixpublic static final MatrixM2x2F transpose(MatrixM2x2F m)
m, writing the resulting matrix
to m.m - The input matrix.mpublic static final MatrixM2x2F transpose(MatrixReadable2x2FType m, MatrixM2x2F out)
m, writing the resulting matrix
to out.m - The input matrix.out - The output matrix.outpublic final float get(int row,
int column)
row - The rowcolumn - The columnpublic final FloatBuffer getFloatBuffer()
getFloatBuffer in interface MatrixReadableFTypepublic final void getRow2F(int row,
VectorM2F out)
MatrixReadable2x2FTyperow, saving the result to out.getRow2F in interface MatrixReadable2x2FTyperow - The index of the row, starting at 0.out - The output vector.public final float getRowColumnF(int row,
int column)
getRowColumnF in interface MatrixReadableFTyperow - The rowcolumn - The columnrow , column
column.public final MatrixM2x2F set(int row, int column, float value)
row - The rowcolumn - The columnvalue - The valueCopyright © 2014 <code@io7m.com> http://io7m.com