Package ej.microvg
Class Matrix
- java.lang.Object
-
- ej.microvg.Matrix
-
public class Matrix extends Object
Represents a 3x3 matrix for transforming coordinates.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidpostConcat(Matrix other)Postconcats the matrix with the specified matrix.voidpostRotate(float degrees)Postconcats the matrix with the specified rotation.voidpostScale(float sx, float sy)Postconcats the matrix with the specified scale.voidpostTranslate(float dx, float dy)Postconcats the matrix with the specified translation.voidpreConcat(Matrix other)Preconcats the matrix with the specified matrix.voidpreRotate(float degrees)Preconcats the matrix with the specified rotation.voidpreScale(float sx, float sy)Preconcats the matrix with the specified scale.voidpreTranslate(float dx, float dy)Preconcats the matrix with the specified translation.voidreset()Resets the matrix to identity.voidset(Matrix source)Deep copies the given matrix into this matrix.voidsetConcat(Matrix a, Matrix b)Sets the matrix to the concatenation of the two specified matrices.voidsetRotate(float degrees)Sets the matrix to rotate about (0,0) by the specified number of degrees.voidsetScale(float sx, float sy)Sets the matrix to scale by (sx, sy).voidsetTranslate(float dx, float dy)Sets the matrix to translate by (dx, dy).
-
-
-
Constructor Detail
-
Matrix
public Matrix()
Creates an identity matrix.
-
Matrix
public Matrix(Matrix source)
Creates a matrix that is a deep copy of the given matrix.- Parameters:
source- the matrix to copy from
-
-
Method Detail
-
set
public void set(Matrix source)
Deep copies the given matrix into this matrix.- Parameters:
source- the matrix to copy from
-
reset
public void reset()
Resets the matrix to identity.
-
setTranslate
public void setTranslate(float dx, float dy)Sets the matrix to translate by (dx, dy).- Parameters:
dx- the translation on xdy- the translation on y
-
setScale
public void setScale(float sx, float sy)Sets the matrix to scale by (sx, sy).- Parameters:
sx- the scale on xsy- the scale on y
-
setRotate
public void setRotate(float degrees)
Sets the matrix to rotate about (0,0) by the specified number of degrees.- Parameters:
degrees- the degrees to rotate
-
setConcat
public void setConcat(Matrix a, Matrix b)
Sets the matrix to the concatenation of the two specified matrices.Either of the two matrices may also be the target matrix, that is
matrixA.setConcat(matrixA, matrixB);is valid.- Parameters:
a- the first matrixb- the second matrix
-
preTranslate
public void preTranslate(float dx, float dy)Preconcats the matrix with the specified translation. M' = M * T(dx, dy)- Parameters:
dx- the translation on xdy- the translation on y
-
preScale
public void preScale(float sx, float sy)Preconcats the matrix with the specified scale. M' = M * S(sx, sy)- Parameters:
sx- the scale on xsy- the scale on y
-
preRotate
public void preRotate(float degrees)
Preconcats the matrix with the specified rotation. M' = M * R(degrees)- Parameters:
degrees- the degrees to rotate
-
preConcat
public void preConcat(Matrix other)
Preconcats the matrix with the specified matrix. M' = M * other- Parameters:
other- the matrix to concat with
-
postTranslate
public void postTranslate(float dx, float dy)Postconcats the matrix with the specified translation. M' = T(dx, dy) * M- Parameters:
dx- the translation on xdy- the translation on y
-
postScale
public void postScale(float sx, float sy)Postconcats the matrix with the specified scale. M' = S(sx, sy) * M- Parameters:
sx- the scale on xsy- the scale on y
-
postRotate
public void postRotate(float degrees)
Postconcats the matrix with the specified rotation. M' = R(degrees) * M- Parameters:
degrees- the degrees to rotate
-
postConcat
public void postConcat(Matrix other)
Postconcats the matrix with the specified matrix. M' = other * M- Parameters:
other- the matrix to concat with
-
-