-
public interface PMatrixA matrix is used to define graphical transformations. PMatrix is the common interface for both the 2D and 3D matrix classes in Processing. A matrix is a grid of numbers, which can be multiplied by a vector to give another vector. Multiplying a point by a particular matrix might translate it, rotate it, or carry out a combination of transformations. Multiplying matrices by each other combines their effects; use theapplyandpreApplymethods for this.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidapply(float n00, float n01, float n02, float n10, float n11, float n12)Multiply this matrix by another.voidapply(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33)Multiply this matrix by another.voidapply(PMatrix source)Multiply this matrix by another.voidapply(PMatrix2D source)Multiply this matrix by another.voidapply(PMatrix3D source)Multiply this matrix by another.floatdeterminant()PMatrixget()Returns a copy of this PMatrix.float[]get(float[] target)Copies the matrix contents into a float array.booleaninvert()Invert this matrix.float[]mult(float[] source, float[] target)Multiply a multi-element vector against this matrix.PVectormult(PVector source, PVector target)Multiply source by this matrix, and return the result.voidpreApply(float n00, float n01, float n02, float n10, float n11, float n12)Apply another matrix to the left of this one.voidpreApply(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33)Apply another matrix to the left of this one.voidpreApply(PMatrix left)Apply another matrix to the left of this one.voidpreApply(PMatrix2D left)Apply another matrix to the left of this one.voidpreApply(PMatrix3D left)Apply another matrix to the left of this one.voidreset()Make this an identity matrix.voidrotate(float angle)voidrotate(float angle, float v0, float v1, float v2)voidrotateX(float angle)voidrotateY(float angle)voidrotateZ(float angle)voidscale(float s)voidscale(float sx, float sy)voidscale(float x, float y, float z)voidset(float[] source)Set the contents of this matrix to the contents of source.voidset(float m00, float m01, float m02, float m10, float m11, float m12)Set the matrix content to this 2D matrix or its 3D equivalent.voidset(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)Set the matrix content to the 3D matrix supplied, if this matrix is 3D.voidset(PMatrix src)Make this matrix become a copy of src.voidshearX(float angle)voidshearY(float angle)voidtranslate(float tx, float ty)voidtranslate(float tx, float ty, float tz)voidtranspose()Transpose this matrix; rows become columns and columns rows.
-
-
-
Method Detail
-
reset
void reset()
Make this an identity matrix. Multiplying by it will have no effect.
-
get
PMatrix get()
Returns a copy of this PMatrix.
-
get
float[] get(float[] target)
Copies the matrix contents into a float array. If target is null (or not the correct size), a new array will be created.
-
set
void set(PMatrix src)
Make this matrix become a copy of src.
-
set
void set(float[] source)
Set the contents of this matrix to the contents of source. Fills the matrix left-to-right, starting in the top row.
-
set
void set(float m00, float m01, float m02, float m10, float m11, float m12)Set the matrix content to this 2D matrix or its 3D equivalent.
-
set
void set(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)Set the matrix content to the 3D matrix supplied, if this matrix is 3D.
-
translate
void translate(float tx, float ty)
-
translate
void translate(float tx, float ty, float tz)
-
rotate
void rotate(float angle)
-
rotateX
void rotateX(float angle)
-
rotateY
void rotateY(float angle)
-
rotateZ
void rotateZ(float angle)
-
rotate
void rotate(float angle, float v0, float v1, float v2)
-
scale
void scale(float s)
-
scale
void scale(float sx, float sy)
-
scale
void scale(float x, float y, float z)
-
shearX
void shearX(float angle)
-
shearY
void shearY(float angle)
-
apply
void apply(PMatrix source)
Multiply this matrix by another.
-
apply
void apply(PMatrix2D source)
Multiply this matrix by another.
-
apply
void apply(PMatrix3D source)
Multiply this matrix by another.
-
apply
void apply(float n00, float n01, float n02, float n10, float n11, float n12)Multiply this matrix by another.
-
apply
void apply(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33)Multiply this matrix by another.
-
preApply
void preApply(PMatrix left)
Apply another matrix to the left of this one.
-
preApply
void preApply(PMatrix2D left)
Apply another matrix to the left of this one.
-
preApply
void preApply(PMatrix3D left)
Apply another matrix to the left of this one. 3D only.
-
preApply
void preApply(float n00, float n01, float n02, float n10, float n11, float n12)Apply another matrix to the left of this one.
-
preApply
void preApply(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33)Apply another matrix to the left of this one. 3D only.
-
mult
PVector mult(PVector source, PVector target)
Multiply source by this matrix, and return the result. The result will be stored in target if target is non-null, and target will then be the matrix returned. This improves performance if you reuse target, so it's recommended if you call this many times in draw().
-
mult
float[] mult(float[] source, float[] target)Multiply a multi-element vector against this matrix. Supplying and recycling a target array improves performance, so it's recommended if you call this many times in draw().
-
transpose
void transpose()
Transpose this matrix; rows become columns and columns rows.
-
invert
boolean invert()
Invert this matrix. Will not necessarily succeed, because some matrices map more than one point to the same image point, and so are irreversible.- Returns:
- true if successful
-
determinant
float determinant()
- Returns:
- the determinant of the matrix
-
-