public class MatrixM2x2D extends Object implements MatrixReadable2x2DType
A 2x2 mutable matrix type with double precision elements.
Values of type MatrixM2x2D 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 |
|---|
MatrixM2x2D()
Construct a new matrix, initialized to the identity matrix.
|
MatrixM2x2D(MatrixReadable2x2DType source)
Construct a new copy of the given matrix.
|
| Modifier and Type | Method and Description |
|---|---|
static MatrixM2x2D |
add(MatrixReadable2x2DType m0,
MatrixReadable2x2DType m1,
MatrixM2x2D out)
Elementwise add of matrices
m0 and m1. |
static MatrixM2x2D |
addInPlace(MatrixM2x2D m0,
MatrixReadable2x2DType m1)
Elementwise add of matrices
m0 and m1,
returning the result in m0. |
static MatrixM2x2D |
addRowScaled(MatrixM2x2D m,
int row_a,
int row_b,
int row_c,
double 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 MatrixM2x2D |
addRowScaled(MatrixReadable2x2DType m,
int row_a,
int row_b,
int row_c,
double r,
MatrixM2x2D 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 MatrixM2x2D |
copy(MatrixReadable2x2DType input,
MatrixM2x2D output)
Copy the contents of the matrix
input to the matrix
output, completely replacing all elements. |
static double |
determinant(MatrixReadable2x2DType m)
Calculate the determinant of the matrix
m. |
static DoubleBuffer |
doubleBuffer(MatrixM2x2D m)
Return a view of the buffer that backs this matrix.
|
boolean |
equals(Object obj) |
static MatrixM2x2D |
exchangeRows(MatrixM2x2D 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 MatrixM2x2D |
exchangeRows(MatrixReadable2x2DType m,
int row_a,
int row_b,
MatrixM2x2D out)
Exchange two rows
row_a and row row_b of the
matrix m, saving the exchanged rows to out . |
double |
get(int row,
int column) |
static double |
get(MatrixReadable2x2DType m,
int row,
int column)
Retrieve the value from the matrix
m at row row
, column column. |
DoubleBuffer |
getDoubleBuffer() |
void |
getRow2D(int row,
VectorM2D out)
Retrieve row
row, saving the result to out. |
double |
getRowColumnD(int row,
int column) |
int |
hashCode() |
static com.io7m.jfunctional.OptionType<MatrixM2x2D> |
invert(MatrixReadable2x2DType m,
MatrixM2x2D out)
Calculate the inverse of the matrix
m, saving the resulting
matrix to out. |
static com.io7m.jfunctional.OptionType<MatrixM2x2D> |
invertInPlace(MatrixM2x2D m)
Calculate the inverse of the matrix
m, saving the resulting
matrix to m. |
static MatrixM2x2D |
multiply(MatrixM2x2D m0,
MatrixReadable2x2DType m1)
Multiply the matrix
m0 with the matrix m1,
writing the result to m0. |
static MatrixM2x2D |
multiply(MatrixReadable2x2DType m0,
MatrixReadable2x2DType m1,
MatrixM2x2D out)
Multiply the matrix
m0 with the matrix m1,
writing the result to out. |
static VectorM2D |
multiplyVector2D(MatrixReadable2x2DType m,
VectorReadable2DType v,
VectorM2D out)
Multiply the matrix
m with the vector v,
writing the resulting vector to out. |
static VectorM2D |
row(MatrixReadable2x2DType m,
int row,
VectorM2D out)
Return row
row of the matrix m in the vector
out. |
static MatrixM2x2D |
scale(MatrixM2x2D m,
double r)
Scale all elements of the matrix
m by the scaling value
r, saving the result in m. |
static MatrixM2x2D |
scale(MatrixReadable2x2DType m,
double r,
MatrixM2x2D out)
Scale all elements of the matrix
m by the scaling value
r, saving the result in out. |
static MatrixM2x2D |
scaleRow(MatrixM2x2D m,
int row,
double r)
Scale row
r of the matrix m by r,
saving the result to row r of m. |
static MatrixM2x2D |
scaleRow(MatrixReadable2x2DType m,
int row,
double r,
MatrixM2x2D out)
Scale row
r of the matrix m by r,
saving the result to row r of out. |
MatrixM2x2D |
set(int row,
int column,
double value) |
static MatrixM2x2D |
set(MatrixM2x2D m,
int row,
int column,
double value)
Set the value in the matrix
m at row row,
column column to value. |
static MatrixM2x2D |
setIdentity(MatrixM2x2D m)
Set the given matrix
m to the identity matrix. |
static MatrixM2x2D |
setZero(MatrixM2x2D m)
Set the given matrix
m to the zero matrix. |
String |
toString() |
static double |
trace(MatrixReadable2x2DType m)
Return the trace of the matrix
m. |
static MatrixM2x2D |
transpose(MatrixM2x2D m)
Transpose the given matrix
m, writing the resulting matrix
to m. |
static MatrixM2x2D |
transpose(MatrixReadable2x2DType m,
MatrixM2x2D out)
Transpose the given matrix
m, writing the resulting matrix
to out. |
public MatrixM2x2D()
public MatrixM2x2D(MatrixReadable2x2DType source)
source - The source matrix.public static final MatrixM2x2D add(MatrixReadable2x2DType m0, MatrixReadable2x2DType m1, MatrixM2x2D out)
m0 and m1.m0 - The left input matrix.m1 - The right input matrix.out - The output matrix.outpublic static final MatrixM2x2D addInPlace(MatrixM2x2D m0, MatrixReadable2x2DType m1)
m0 and m1,
returning the result in m0.m0 - The left input matrix.m1 - The right input matrix.m0public static final MatrixM2x2D addRowScaled(MatrixM2x2D m, int row_a, int row_b, int row_c, double 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 MatrixM2x2D addRowScaled(MatrixReadable2x2DType m, int row_a, int row_b, int row_c, double r, MatrixM2x2D 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 MatrixM2x2D copy(MatrixReadable2x2DType input, MatrixM2x2D output)
input to the matrix
output, completely replacing all elements.input - The input vector.output - The output vector.outputpublic static final double determinant(MatrixReadable2x2DType m)
m.m - The input matrix.public static final DoubleBuffer doubleBuffer(MatrixM2x2D m)
m - The input matrix.public static final MatrixM2x2D exchangeRows(MatrixM2x2D 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 MatrixM2x2D exchangeRows(MatrixReadable2x2DType m, int row_a, int row_b, MatrixM2x2D 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 double get(MatrixReadable2x2DType m, int row, int column)
m at row row
, column column.row - The row.column - The column.m - The matrix.public static final com.io7m.jfunctional.OptionType<MatrixM2x2D> invert(MatrixReadable2x2DType m, MatrixM2x2D 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.m, if any.determinant(MatrixReadable2x2DType)public static final com.io7m.jfunctional.OptionType<MatrixM2x2D> invertInPlace(MatrixM2x2D 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.m, if any.determinant(MatrixReadable2x2DType)public static final MatrixM2x2D multiply(MatrixM2x2D m0, MatrixReadable2x2DType m1)
m0 with the matrix m1,
writing the result to m0.m0 - The left input matrix.m1 - The right input matrix.outpublic static final MatrixM2x2D multiply(MatrixReadable2x2DType m0, MatrixReadable2x2DType m1, MatrixM2x2D 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 VectorM2D multiplyVector2D(MatrixReadable2x2DType m, VectorReadable2DType v, VectorM2D 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 VectorM2D row(MatrixReadable2x2DType m, int row, VectorM2D out)
row of the matrix m in the vector
out.row - The row.out - The output vector.m - The matrix.public static final MatrixM2x2D scale(MatrixM2x2D m, double r)
m by the scaling value
r, saving the result in m.m - The input matrix.r - The scaling value.mpublic static final MatrixM2x2D scale(MatrixReadable2x2DType m, double r, MatrixM2x2D out)
m by the scaling value
r, saving the result in out.m - The input matrix.r - The scaling value.out - The output row.mpublic static final MatrixM2x2D scaleRow(MatrixM2x2D m, int row, double 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.outpublic static final MatrixM2x2D scaleRow(MatrixReadable2x2DType m, int row, double r, MatrixM2x2D 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 MatrixM2x2D set(MatrixM2x2D m, int row, int column, double value)
m at row row,
column column to value.m - The input matrixrow - The rowcolumn - The columnvalue - The valuepublic static final MatrixM2x2D setIdentity(MatrixM2x2D m)
m to the identity matrix.m - The matrixmpublic static final MatrixM2x2D setZero(MatrixM2x2D m)
m to the zero matrix.m - The matrixmpublic static final double trace(MatrixReadable2x2DType m)
m. The trace is defined as
the sum of the diagonal elements of the matrix.m - The input matrixpublic static final MatrixM2x2D transpose(MatrixM2x2D m)
m, writing the resulting matrix
to m.m - The input matrix.mpublic static final MatrixM2x2D transpose(MatrixReadable2x2DType m, MatrixM2x2D out)
m, writing the resulting matrix
to out.m - The input matrix.out - The output matrix.outpublic final double get(int row,
int column)
row - The row.column - The column.public final DoubleBuffer getDoubleBuffer()
getDoubleBuffer in interface MatrixReadableDTypepublic final void getRow2D(int row,
VectorM2D out)
MatrixReadable2x2DTyperow, saving the result to out.getRow2D in interface MatrixReadable2x2DTyperow - The index of the row, starting at 0.out - The output vector.public final double getRowColumnD(int row,
int column)
getRowColumnD in interface MatrixReadableDTyperow - The rowcolumn - The columnrow , column
column.public final MatrixM2x2D set(int row, int column, double value)
row - The row.column - The column.value - The value.Copyright © 2014 <code@io7m.com> http://io7m.com