Package processing.core
Class PMatrix3D
java.lang.Object
processing.core.PMatrix3D
- All Implemented Interfaces:
PMatrix
4x4 matrix implementation.
Matrices are used to describe a transformation; see
PMatrix
for a
general description. This matrix looks like the following when multiplying
a vector (x, y, z, w) in mult()
.
[m00 m01 m02 m03][x] [m00*x + m01*y + m02*z + m03*w] [x'] [m10 m11 m12 m13][y] = [m10*x + m11*y + m12*z + m13*w] = [y'] [m20 m21 m22 m23][z] [m20*x + m21*y + m22*z + m23*w] [z'] [m30 m31 m32 m33][w] [m30*x + m31*y + m32*z + m33*w] [w'](x', y', z', w') is returned. The values in the matrix determine the transformation. They are modified by the various transformation functions. To transform 3D coordinates, w is set to 1, amd w' is made to be 1 by setting the bottom row of the matrix to
[0 0 0 1]
. The
resulting point is then (x', y', z').-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(float n00, float n01, float n02, float n10, float n11, float n12) Multiply this matrix by another.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.void
Multiply this matrix by another.void
Multiply this matrix by another.void
Multiply this matrix by another.float
get()
Returns a copy of this PMatrix.float[]
get
(float[] target) Copies the matrix contents into a 16 entry float array.boolean
invert()
Invert this matrix.float[]
mult
(float[] source, float[] target) Multiply a three or four element vector against this matrix.Multiply source by this matrix, and return the result.float
multW
(float x, float y, float z) Returns the fourth element of the result of multiplying the vector (x, y, z) by this matrix.float
multW
(float x, float y, float z, float w) Returns the w-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix.float
multX
(float x, float y) Returns the x-coordinate of the result of multiplying the point (x, y) by this matrix.float
multX
(float x, float y, float z) Returns the x-coordinate of the result of multiplying the point (x, y, z) by this matrix.float
multX
(float x, float y, float z, float w) Returns the x-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix.float
multY
(float x, float y) Returns the y-coordinate of the result of multiplying the point (x, y) by this matrix.float
multY
(float x, float y, float z) Returns the y-coordinate of the result of multiplying the point (x, y, z) by this matrix.float
multY
(float x, float y, float z, float w) Returns the y-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix.float
multZ
(float x, float y, float z) Returns the z-coordinate of the result of multiplying the point (x, y, z) by this matrix.float
multZ
(float x, float y, float z, float w) Returns the z-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix.void
preApply
(float n00, float n01, float n02, float n10, float n11, float n12) Apply the 3D equivalent of the 2D matrix supplied to the left of this one.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.void
Apply another matrix to the left of this one.void
Apply the 3D equivalent of the 2D matrix supplied to the left of this one.void
Apply another matrix to the left of this one.void
print()
void
reset()
Make this an identity matrix.void
rotate
(float angle) void
rotate
(float angle, float v0, float v1, float v2) void
rotateX
(float angle) void
rotateY
(float angle) void
rotateZ
(float angle) void
scale
(float s) void
scale
(float sx, float sy) void
scale
(float x, float y, float z) void
set
(float[] source) Set the contents of this matrix to the contents of source.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.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.void
Make this matrix become a copy of src.void
shearX
(float angle) void
shearY
(float angle) void
translate
(float tx, float ty) void
translate
(float tx, float ty, float tz) void
Transpose this matrix; rows become columns and columns rows.
-
Field Details
-
m00
public float m00 -
m01
public float m01 -
m02
public float m02 -
m03
public float m03 -
m10
public float m10 -
m11
public float m11 -
m12
public float m12 -
m13
public float m13 -
m20
public float m20 -
m21
public float m21 -
m22
public float m22 -
m23
public float m23 -
m30
public float m30 -
m31
public float m31 -
m32
public float m32 -
m33
public float m33
-
-
Constructor Details
-
PMatrix3D
public PMatrix3D() -
PMatrix3D
public PMatrix3D(float m00, float m01, float m02, float m10, float m11, float m12) -
PMatrix3D
public PMatrix3D(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) -
PMatrix3D
-
-
Method Details
-
reset
public void reset()Description copied from interface:PMatrix
Make this an identity matrix. Multiplying by it will have no effect. -
get
Returns a copy of this PMatrix. -
get
public float[] get(float[] target) Copies the matrix contents into a 16 entry float array. If target is null (or not the correct size), a new array will be created. -
set
Description copied from interface:PMatrix
Make this matrix become a copy of src. -
set
public void set(float[] source) Description copied from interface:PMatrix
Set the contents of this matrix to the contents of source. Fills the matrix left-to-right, starting in the top row. -
set
public void set(float m00, float m01, float m02, float m10, float m11, float m12) Description copied from interface:PMatrix
Set the matrix content to this 2D matrix or its 3D equivalent. -
set
public 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) Description copied from interface:PMatrix
Set the matrix content to the 3D matrix supplied, if this matrix is 3D. -
translate
public void translate(float tx, float ty) -
translate
public void translate(float tx, float ty, float tz) -
rotate
public void rotate(float angle) -
rotateX
public void rotateX(float angle) -
rotateY
public void rotateY(float angle) -
rotateZ
public void rotateZ(float angle) -
rotate
public void rotate(float angle, float v0, float v1, float v2) -
scale
public void scale(float s) -
scale
public void scale(float sx, float sy) -
scale
public void scale(float x, float y, float z) -
shearX
public void shearX(float angle) -
shearY
public void shearY(float angle) -
apply
Description copied from interface:PMatrix
Multiply this matrix by another. -
apply
Description copied from interface:PMatrix
Multiply this matrix by another. -
apply
Description copied from interface:PMatrix
Multiply this matrix by another. -
apply
public void apply(float n00, float n01, float n02, float n10, float n11, float n12) Description copied from interface:PMatrix
Multiply this matrix by another. -
apply
public 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) Description copied from interface:PMatrix
Multiply this matrix by another. -
preApply
Apply the 3D equivalent of the 2D matrix supplied to the left of this one. -
preApply
Apply another matrix to the left of this one. -
preApply
Apply another matrix to the left of this one. -
preApply
public void preApply(float n00, float n01, float n02, float n10, float n11, float n12) Apply the 3D equivalent of the 2D matrix supplied to the left of this one. -
preApply
public 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. -
mult
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
public float[] mult(float[] source, float[] target) Multiply a three or four element vector against this matrix. If out is null or not length 3 or 4, a new float array (length 3) will be returned. Supplying and recycling a target array improves performance, so it's recommended if you call this many times in draw. -
multX
public float multX(float x, float y) Returns the x-coordinate of the result of multiplying the point (x, y) by this matrix. -
multY
public float multY(float x, float y) Returns the y-coordinate of the result of multiplying the point (x, y) by this matrix. -
multX
public float multX(float x, float y, float z) Returns the x-coordinate of the result of multiplying the point (x, y, z) by this matrix. -
multY
public float multY(float x, float y, float z) Returns the y-coordinate of the result of multiplying the point (x, y, z) by this matrix. -
multZ
public float multZ(float x, float y, float z) Returns the z-coordinate of the result of multiplying the point (x, y, z) by this matrix. -
multW
public float multW(float x, float y, float z) Returns the fourth element of the result of multiplying the vector (x, y, z) by this matrix. (Acts as if w = 1 was supplied.) -
multX
public float multX(float x, float y, float z, float w) Returns the x-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix. -
multY
public float multY(float x, float y, float z, float w) Returns the y-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix. -
multZ
public float multZ(float x, float y, float z, float w) Returns the z-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix. -
multW
public float multW(float x, float y, float z, float w) Returns the w-coordinate of the result of multiplying the vector (x, y, z, w) by this matrix. -
transpose
public void transpose()Transpose this matrix; rows become columns and columns rows. -
invert
public 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. -
determinant
public float determinant()- Specified by:
determinant
in interfacePMatrix
- Returns:
- the determinant of the matrix
-
print
public void print()
-