public class MatrixM3x3F extends Object implements MatrixReadable3x3FType
A 3x3 mutable matrix type with single precision elements.
Values of type MatrixM3x3F 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).
| Modifier and Type | Class and Description |
|---|---|
static class |
MatrixM3x3F.Context
The Context type contains the minimum storage required for all of the
functions of the
MatrixM3x3F class. |
| Constructor and Description |
|---|
MatrixM3x3F()
Construct a new identity matrix.
|
MatrixM3x3F(MatrixReadable3x3FType source)
Construct a new copy of the given matrix.
|
| Modifier and Type | Method and Description |
|---|---|
static MatrixM3x3F |
add(MatrixReadable3x3FType m0,
MatrixReadable3x3FType m1,
MatrixM3x3F out)
Elementwise add of matrices
m0 and m1. |
static MatrixM3x3F |
addInPlace(MatrixM3x3F m0,
MatrixM3x3F m1)
Elementwise add of matrices
m0 and m1,
returning the result in m0. |
static MatrixM3x3F |
addRowScaled(MatrixReadable3x3FType m,
int row_a,
int row_b,
int row_c,
double r,
MatrixM3x3F 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 MatrixM3x3F |
addRowScaledInPlace(MatrixM3x3F 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 MatrixM3x3F |
copy(MatrixReadable3x3FType input,
MatrixM3x3F output)
Copy the contents of the matrix
input to the matrix
output, completely replacing all elements. |
static double |
determinant(MatrixReadable3x3FType m)
Calculate the determinant of the matrix
m. |
boolean |
equals(Object obj) |
static MatrixM3x3F |
exchangeRows(MatrixReadable3x3FType m,
int row_a,
int row_b,
MatrixM3x3F out)
Exchange the row
row_a and row row_b of the
matrix m, saving the exchanged rows to out . |
static MatrixM3x3F |
exchangeRowsInPlace(MatrixM3x3F m,
int row_a,
int row_b)
Exchange the row
row_a and row row_b of the
matrix m, saving the exchanged rows to m . |
static FloatBuffer |
floatBuffer(MatrixM3x3F m) |
float |
get(int row,
int column) |
static float |
get(MatrixReadable3x3FType m,
int row,
int column) |
FloatBuffer |
getFloatBuffer() |
void |
getRow3F(int row,
VectorM3F out)
Retrieve row
row, saving the result to out. |
float |
getRowColumnF(int row,
int column) |
int |
hashCode() |
static com.io7m.jfunctional.OptionType<MatrixM3x3F> |
invert(MatrixReadable3x3FType m,
MatrixM3x3F out)
Calculate the inverse of the matrix
m, saving the resulting
matrix to out. |
static com.io7m.jfunctional.OptionType<MatrixM3x3F> |
invertInPlace(MatrixM3x3F m)
Calculate the inverse of the matrix
m, saving the resulting
matrix to m. |
static void |
lookAtWithContext(MatrixM3x3F.Context context,
VectorReadable3FType origin,
VectorReadable3FType target,
VectorReadable3FType up,
MatrixM3x3F out_matrix,
VectorM3F out_translation)
Calculate a rotation and translation representing a "camera" looking from
the point
origin to the point target. |
static MatrixM3x3F |
makeRotation(double angle,
VectorReadable3FType axis)
Generate and return a matrix that represents a rotation of
angle radians around the axis axis. |
static MatrixM3x3F |
makeRotation(double angle,
VectorReadable3FType axis,
MatrixM3x3F out)
Generate a matrix that represents a rotation of
angle
radians around the axis axis and save to out. |
static MatrixM3x3F |
makeTranslation2F(VectorReadable2FType v,
MatrixM3x3F out)
Create a translation matrix that represents a translation by the vector
v, writing the resulting matrix to out. |
static MatrixM3x3F |
makeTranslation2I(VectorReadable2IType v,
MatrixM3x3F out)
Create a translation matrix that represents a translation by the vector
v, writing the resulting matrix to out. |
static MatrixM3x3F |
multiply(MatrixReadable3x3FType m0,
MatrixReadable3x3FType m1,
MatrixM3x3F out)
Multiply the matrix
m0 with the matrix m1,
writing the result to out. |
static MatrixM3x3F |
multiplyInPlace(MatrixM3x3F m0,
MatrixReadable3x3FType m1)
Multiply the matrix
m0 with the matrix m1,
writing the result to m0. |
static VectorM3F |
multiplyVector3F(MatrixReadable3x3FType m,
VectorReadable3FType v,
VectorM3F out)
Multiply the matrix
m with the vector v,
writing the resulting vector to out. |
static MatrixM3x3F |
rotate(double angle,
MatrixReadable3x3FType m,
VectorReadable3FType axis,
MatrixM3x3F out)
Rotate the matrix
m by angle radians around the
axis axis, saving the result into out. |
static MatrixM3x3F |
rotateInPlace(double angle,
MatrixM3x3F m,
VectorReadable3FType axis)
Rotate the matrix
m by angle radians around the
axis axis, saving the result into m. |
static MatrixM3x3F |
rotateInPlaceWithContext(MatrixM3x3F.Context context,
double angle,
MatrixM3x3F m,
VectorReadable3FType axis)
Rotate the matrix
m by angle radians around the
axis axis, saving the result into m. |
static MatrixM3x3F |
rotateWithContext(MatrixM3x3F.Context context,
double angle,
MatrixReadable3x3FType m,
VectorReadable3FType axis,
MatrixM3x3F out)
Rotate the matrix
m by angle radians around the
axis axis, saving the result into out. |
static VectorM3F |
row(MatrixReadable3x3FType m,
int row,
VectorM3F out) |
static MatrixM3x3F |
scale(MatrixReadable3x3FType m,
double r,
MatrixM3x3F out)
Scale all elements of the matrix
m by the scaling value
r, saving the result in out. |
static MatrixM3x3F |
scaleInPlace(MatrixM3x3F m,
double r)
Scale all elements of the matrix
m by the scaling value
r, saving the result in m. |
static MatrixM3x3F |
scaleRow(MatrixReadable3x3FType m,
int row,
double r,
MatrixM3x3F out)
Scale row
r of the matrix m by r,
saving the result to row r of out. |
static MatrixM3x3F |
scaleRowInPlace(MatrixM3x3F m,
int row,
double r)
Scale row
r of the matrix m by r,
saving the result to row r of m. |
MatrixM3x3F |
set(int row,
int column,
float value)
Set the value at the given row and column.
|
static MatrixM3x3F |
set(MatrixM3x3F m,
int row,
int column,
float value)
Set the value in the matrix
m at row row,
column column to value. |
static MatrixM3x3F |
setIdentity(MatrixM3x3F m)
Set the given matrix
m to the identity matrix. |
static MatrixM3x3F |
setZero(MatrixM3x3F m)
Set the given matrix
m to the zero matrix. |
String |
toString() |
static double |
trace(MatrixReadable3x3FType m)
Return the trace of the matrix
m. |
static MatrixM3x3F |
translateByVector2F(MatrixReadable3x3FType m,
VectorReadable2FType v,
MatrixM3x3F out)
Translate the matrix
m by the vector v, storing
the resulting matrix in out. |
static MatrixM3x3F |
translateByVector2FInPlace(MatrixM3x3F m,
VectorReadable2FType v)
Translate the matrix
m by the vector v, storing
the resulting matrix in m. |
static MatrixM3x3F |
translateByVector2I(MatrixReadable3x3FType m,
VectorReadable2IType v,
MatrixM3x3F out)
Translate the matrix
m by the vector v, storing
the resulting matrix in out. |
static MatrixM3x3F |
translateByVector2IInPlace(MatrixM3x3F m,
VectorReadable2IType v)
Translate the matrix
m by the vector v, storing
the resulting matrix in m. |
static MatrixM3x3F |
transpose(MatrixReadable3x3FType m,
MatrixM3x3F out)
Transpose the given matrix
m, writing the resulting matrix
to out. |
static MatrixM3x3F |
transposeInPlace(MatrixM3x3F m)
Transpose the given matrix
m, writing the resulting matrix
to m. |
public MatrixM3x3F()
public MatrixM3x3F(MatrixReadable3x3FType source)
source - The source matrix.public static final MatrixM3x3F add(MatrixReadable3x3FType m0, MatrixReadable3x3FType m1, MatrixM3x3F out)
m0 and m1.m0 - The left input matrix.m1 - The right input matrix.out - The output matrix.outpublic static final MatrixM3x3F addInPlace(MatrixM3x3F m0, MatrixM3x3F m1)
m0 and m1,
returning the result in m0.m0 - The left input matrix.m1 - The right input matrix.m0public static final MatrixM3x3F addRowScaled(MatrixReadable3x3FType m, int row_a, int row_b, int row_c, double r, MatrixM3x3F 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 MatrixM3x3F addRowScaledInPlace(MatrixM3x3F 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 MatrixM3x3F copy(MatrixReadable3x3FType input, MatrixM3x3F output)
input to the matrix
output, completely replacing all elements.input - The input vector.output - The output vector.outputpublic static final double determinant(MatrixReadable3x3FType m)
m.m - The input matrix.public static final MatrixM3x3F exchangeRows(MatrixReadable3x3FType m, int row_a, int row_b, MatrixM3x3F out)
Exchange the row 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 MatrixM3x3F exchangeRowsInPlace(MatrixM3x3F m, int row_a, int row_b)
Exchange the row 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(MatrixM3x3F m)
m - The input matrix.public static final float get(MatrixReadable3x3FType m, int row, int column)
row - The rowcolumn - The columnm - The input matrixm at row row,
column column.public static final com.io7m.jfunctional.OptionType<MatrixM3x3F> invert(MatrixReadable3x3FType m, MatrixM3x3F 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.m - The input matrix.out - The output matrix.outdeterminant(MatrixReadable3x3FType)public static final com.io7m.jfunctional.OptionType<MatrixM3x3F> invertInPlace(MatrixM3x3F 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.m - The input matrix.mdeterminant(MatrixReadable3x3FType)public static final void lookAtWithContext(MatrixM3x3F.Context context, VectorReadable3FType origin, VectorReadable3FType target, VectorReadable3FType up, MatrixM3x3F out_matrix, VectorM3F out_translation)
Calculate a rotation and translation representing a "camera" looking from
the point origin to the point target.
target must represent the "up" vector for the camera.
Usually, this is simply a unit vector (0, 1, 0) representing
the Y axis.
The function uses preallocated storage from context.
The view is expressed as a rotation matrix and a translation vector,
written to out_matrix and out_translation,
respectively.
context - Preallocated storageout_matrix - The output matrixout_translation - The output translationorigin - The position of the viewertarget - The target being viewedup - The up vectorpublic static final MatrixM3x3F makeRotation(double angle, VectorReadable3FType axis)
Generate and return a matrix that represents a rotation of
angle radians around the axis axis.
The function assumes a right-handed coordinate system and therefore a positive rotation around any axis represents a counter-clockwise rotation around that axis.
angle - The angle in radians.axis - The axis.outpublic static final MatrixM3x3F makeRotation(double angle, VectorReadable3FType axis, MatrixM3x3F out)
Generate a matrix that represents a rotation of angle
radians around the axis axis and save to out.
The function assumes a right-handed coordinate system and therefore a positive rotation around any axis represents a counter-clockwise rotation around that axis.
angle - The angle in radians.axis - The axis.out - The output matrix.outpublic static final MatrixM3x3F makeTranslation2F(VectorReadable2FType v, MatrixM3x3F out)
v, writing the resulting matrix to out.v - The translation vector.out - The output matrix.outpublic static final MatrixM3x3F makeTranslation2I(VectorReadable2IType v, MatrixM3x3F out)
v, writing the resulting matrix to out.v - The translation vector.out - The output matrix.outpublic static final MatrixM3x3F multiply(MatrixReadable3x3FType m0, MatrixReadable3x3FType m1, MatrixM3x3F out)
m0 with the matrix m1,
writing the result to out.m0 - The left input vector.m1 - The right input vector.out - The output vector.outpublic static final MatrixM3x3F multiplyInPlace(MatrixM3x3F m0, MatrixReadable3x3FType m1)
m0 with the matrix m1,
writing the result to m0.m0 - The left input vector.m1 - The right input vector.outpublic static final VectorM3F multiplyVector3F(MatrixReadable3x3FType m, VectorReadable3FType v, VectorM3F 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 MatrixM3x3F rotate(double angle, MatrixReadable3x3FType m, VectorReadable3FType axis, MatrixM3x3F out)
m by angle radians around the
axis axis, saving the result into out.angle - The angle in radians.m - The input matrix.axis - A vector representing an axis.out - The output matrix.outpublic static final MatrixM3x3F rotateInPlace(double angle, MatrixM3x3F m, VectorReadable3FType axis)
m by angle radians around the
axis axis, saving the result into m.angle - The angle in radians.m - The input matrix.axis - A vector representing an axis.mpublic static final MatrixM3x3F rotateInPlaceWithContext(MatrixM3x3F.Context context, double angle, MatrixM3x3F m, VectorReadable3FType axis)
m by angle radians around the
axis axis, saving the result into m. The
function uses preallocated storage in context to avoid
allocating memory. The function assumes a right-handed coordinate system.context - Preallocated storage.angle - The angle in radians.m - The input matrix.axis - A vector representing an axis.mpublic static final MatrixM3x3F rotateWithContext(MatrixM3x3F.Context context, double angle, MatrixReadable3x3FType m, VectorReadable3FType axis, MatrixM3x3F out)
m by angle radians around the
axis axis, saving the result into out. The
function uses preallocated storage in context to avoid
allocating memory. The function assumes a right-handed coordinate system.context - Preallocated storage.angle - The angle in radians.m - The input matrix.axis - A vector representing an axis.out - The output matrix.outpublic static final VectorM3F row(MatrixReadable3x3FType m, int row, VectorM3F out)
m - The input matrixrow - The rowout - The output vectorrow of the matrix m in the vector
out.public static final MatrixM3x3F scale(MatrixReadable3x3FType m, double r, MatrixM3x3F out)
m by the scaling value
r, saving the result in out.m - The input matrix.r - The scaling value.out - The output matrixoutpublic static final MatrixM3x3F scaleInPlace(MatrixM3x3F 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 MatrixM3x3F scaleRow(MatrixReadable3x3FType m, int row, double r, MatrixM3x3F 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 MatrixM3x3F scaleRowInPlace(MatrixM3x3F 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.mpublic static final MatrixM3x3F set(MatrixM3x3F m, int row, int column, float value)
m at row row,
column column to value.m - The input matrixrow - The rowcolumn - The columnvalue - The valuempublic static final MatrixM3x3F setIdentity(MatrixM3x3F m)
m to the identity matrix.m - The matrixmpublic static final MatrixM3x3F setZero(MatrixM3x3F m)
m to the zero matrix.m - The matrixmpublic static final double trace(MatrixReadable3x3FType m)
m. The trace is defined as
the sum of the diagonal elements of the matrix.m - The input matrixpublic static final MatrixM3x3F translateByVector2F(MatrixReadable3x3FType m, VectorReadable2FType v, MatrixM3x3F out)
m by the vector v, storing
the resulting matrix in out.m - The input matrix.v - The translation vector.out - The output matrix.outpublic static final MatrixM3x3F translateByVector2FInPlace(MatrixM3x3F m, VectorReadable2FType v)
m by the vector v, storing
the resulting matrix in m.m - The input matrix.v - The translation vector.mpublic static final MatrixM3x3F translateByVector2I(MatrixReadable3x3FType m, VectorReadable2IType v, MatrixM3x3F out)
m by the vector v, storing
the resulting matrix in out.m - The input matrix.v - The translation vector.out - The output matrix.outpublic static final MatrixM3x3F translateByVector2IInPlace(MatrixM3x3F m, VectorReadable2IType v)
m by the vector v, storing
the resulting matrix in m.m - The input matrix.v - The translation vector.mpublic static final MatrixM3x3F transpose(MatrixReadable3x3FType m, MatrixM3x3F out)
m, writing the resulting matrix
to out.m - The input matrix.out - The output matrix.outpublic static final MatrixM3x3F transposeInPlace(MatrixM3x3F m)
m, writing the resulting matrix
to m.m - The input matrix.mpublic final float get(int row,
int column)
row - The rowcolumn - The columnpublic final FloatBuffer getFloatBuffer()
getFloatBuffer in interface MatrixReadableFTypepublic final void getRow3F(int row,
VectorM3F out)
MatrixReadable3x3FTyperow, saving the result to out.getRow3F in interface MatrixReadable3x3FTyperow - 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 MatrixM3x3F set(int row, int column, float value)
row - The rowcolumn - The columnvalue - The valuethisCopyright © 2014 <code@io7m.com> http://io7m.com