Class Matrix2f
- java.lang.Object
-
- net.lax1dude.eaglercraft.v1_8.vector.Matrix
-
- net.lax1dude.eaglercraft.v1_8.vector.Matrix2f
-
- All Implemented Interfaces:
java.io.Serializable
public class Matrix2f extends Matrix implements java.io.Serializable
Holds a 2x2 matrix- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Matrix2f
add(Matrix2f left, Matrix2f right, Matrix2f dest)
Add two matrices together and place the result in a third matrix.float
determinant()
Matrix
invert()
Invert this matrixstatic Matrix2f
invert(Matrix2f src, Matrix2f dest)
Invert the source matrix and place the result in the destination matrix.Matrix
load(FloatBuffer buf)
Load from a float buffer.Matrix2f
load(Matrix2f src)
Load from another matrixstatic Matrix2f
load(Matrix2f src, Matrix2f dest)
Copy the source matrix to the destination matrix.Matrix
loadTranspose(FloatBuffer buf)
Load from a float buffer.static Matrix2f
mul(Matrix2f left, Matrix2f right, Matrix2f dest)
Multiply the right matrix by the left and place the result in a third matrix.Matrix
negate()
Negate this matrixMatrix2f
negate(Matrix2f dest)
Negate this matrix and stash the result in another matrix.static Matrix2f
negate(Matrix2f src, Matrix2f dest)
Negate the source matrix and stash the result in the destination matrix.Matrix
setIdentity()
Set this matrix to be the identity matrix.static Matrix2f
setIdentity(Matrix2f src)
Set the source matrix to be the identity matrix.Matrix
setZero()
Set this matrix to 0.static Matrix2f
setZero(Matrix2f src)
Matrix
store(FloatBuffer buf)
Store this matrix in a float buffer.Matrix
storeTranspose(FloatBuffer buf)
Store this matrix in a float buffer.static Matrix2f
sub(Matrix2f left, Matrix2f right, Matrix2f dest)
Subtract the right matrix from the left and place the result in a third matrix.java.lang.String
toString()
Returns a string representation of this matrixstatic Vector2f
transform(Matrix2f left, Vector2f right, Vector2f dest)
Transform a Vector by a matrix and return the result in a destination vector.Matrix
transpose()
Transpose this matrixMatrix2f
transpose(Matrix2f dest)
Transpose this matrix and place the result in another matrix.static Matrix2f
transpose(Matrix2f src, Matrix2f dest)
Transpose the source matrix and place the result in the destination matrix.
-
-
-
Constructor Detail
-
Matrix2f
public Matrix2f()
Constructor for Matrix2f. The matrix is initialised to the identity.
-
Matrix2f
public Matrix2f(Matrix2f src)
Constructor
-
-
Method Detail
-
load
public Matrix2f load(Matrix2f src)
Load from another matrix- Parameters:
src
- The source matrix- Returns:
- this
-
load
public static Matrix2f load(Matrix2f src, Matrix2f dest)
Copy the source matrix to the destination matrix.- Parameters:
src
- The source matrixdest
- The destination matrix, or null if a new one should be created.- Returns:
- The copied matrix
-
load
public Matrix load(FloatBuffer buf)
Load from a float buffer. The buffer stores the matrix in column major (OpenGL) order.
-
loadTranspose
public Matrix loadTranspose(FloatBuffer buf)
Load from a float buffer. The buffer stores the matrix in row major (mathematical) order.- Specified by:
loadTranspose
in classMatrix
- Parameters:
buf
- A float buffer to read from- Returns:
- this
-
store
public Matrix store(FloatBuffer buf)
Store this matrix in a float buffer. The matrix is stored in column major (openGL) order.
-
storeTranspose
public Matrix storeTranspose(FloatBuffer buf)
Store this matrix in a float buffer. The matrix is stored in row major (maths) order.- Specified by:
storeTranspose
in classMatrix
- Parameters:
buf
- The buffer to store this matrix in- Returns:
- this
-
add
public static Matrix2f add(Matrix2f left, Matrix2f right, Matrix2f dest)
Add two matrices together and place the result in a third matrix.- Parameters:
left
- The left source matrixright
- The right source matrixdest
- The destination matrix, or null if a new one is to be created- Returns:
- the destination matrix
-
sub
public static Matrix2f sub(Matrix2f left, Matrix2f right, Matrix2f dest)
Subtract the right matrix from the left and place the result in a third matrix.- Parameters:
left
- The left source matrixright
- The right source matrixdest
- The destination matrix, or null if a new one is to be created- Returns:
- the destination matrix
-
mul
public static Matrix2f mul(Matrix2f left, Matrix2f right, Matrix2f dest)
Multiply the right matrix by the left and place the result in a third matrix.- Parameters:
left
- The left source matrixright
- The right source matrixdest
- The destination matrix, or null if a new one is to be created- Returns:
- the destination matrix
-
transform
public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest)
Transform a Vector by a matrix and return the result in a destination vector.- Parameters:
left
- The left matrixright
- The right vectordest
- The destination vector, or null if a new one is to be created- Returns:
- the destination vector
-
transpose
public Matrix transpose()
Transpose this matrix
-
transpose
public Matrix2f transpose(Matrix2f dest)
Transpose this matrix and place the result in another matrix.- Parameters:
dest
- The destination matrix or null if a new matrix is to be created- Returns:
- the transposed matrix
-
transpose
public static Matrix2f transpose(Matrix2f src, Matrix2f dest)
Transpose the source matrix and place the result in the destination matrix.- Parameters:
src
- The source matrix or null if a new matrix is to be createddest
- The destination matrix or null if a new matrix is to be created- Returns:
- the transposed matrix
-
invert
public Matrix invert()
Invert this matrix
-
invert
public static Matrix2f invert(Matrix2f src, Matrix2f dest)
Invert the source matrix and place the result in the destination matrix.- Parameters:
src
- The source matrix to be inverteddest
- The destination matrix or null if a new matrix is to be created- Returns:
- The inverted matrix, or null if source can't be reverted.
-
toString
public java.lang.String toString()
Returns a string representation of this matrix- Overrides:
toString
in classjava.lang.Object
-
negate
public Matrix2f negate(Matrix2f dest)
Negate this matrix and stash the result in another matrix.- Parameters:
dest
- The destination matrix, or null if a new matrix is to be created- Returns:
- the negated matrix
-
negate
public static Matrix2f negate(Matrix2f src, Matrix2f dest)
Negate the source matrix and stash the result in the destination matrix.- Parameters:
src
- The source matrix to be negateddest
- The destination matrix, or null if a new matrix is to be created- Returns:
- the negated matrix
-
setIdentity
public Matrix setIdentity()
Set this matrix to be the identity matrix.- Specified by:
setIdentity
in classMatrix
- Returns:
- this
-
setIdentity
public static Matrix2f setIdentity(Matrix2f src)
Set the source matrix to be the identity matrix.- Parameters:
src
- The matrix to set to the identity.- Returns:
- The source matrix
-
setZero
public Matrix setZero()
Set this matrix to 0.
-
determinant
public float determinant()
- Specified by:
determinant
in classMatrix
- Returns:
- the determinant of the matrix
-
-