MCPcopy Index your code
hub / github.com/processing/processing / PMatrix2D

Class PMatrix2D

core/src/processing/core/PMatrix2D.java:39–534  ·  view source on GitHub ↗

3x2 affine 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) in mult(). [m00 m01 m02][x] [m00 x + m01 y + m02 1] [x'] [m10 m11 m12][y] = [m10 x

Source from the content-addressed store, hash-verified

37 * They are modified by the various transformation functions.
38 */
39public class PMatrix2D implements PMatrix {
40
41 public float m00, m01, m02;
42 public float m10, m11, m12;
43
44
45 /**
46 * Create a new matrix, set to the identity matrix.
47 */
48 public PMatrix2D() {
49 reset();
50 }
51
52
53 public PMatrix2D(float m00, float m01, float m02,
54 float m10, float m11, float m12) {
55 set(m00, m01, m02,
56 m10, m11, m12);
57 }
58
59
60 public PMatrix2D(PMatrix matrix) {
61 set(matrix);
62 }
63
64
65 public void reset() {
66 set(1, 0, 0,
67 0, 1, 0);
68 }
69
70
71 /**
72 * Returns a copy of this PMatrix.
73 */
74 public PMatrix2D get() {
75 PMatrix2D outgoing = new PMatrix2D();
76 outgoing.set(this);
77 return outgoing;
78 }
79
80
81 /**
82 * Copies the matrix contents into a 6 entry float array.
83 * If target is null (or not the correct size), a new array will be created.
84 * Returned in the order {@code {m00, m01, m02, m10, m11, m12}}.
85 */
86 public float[] get(float[] target) {
87 if ((target == null) || (target.length != 6)) {
88 target = new float[6];
89 }
90 target[0] = m00;
91 target[1] = m01;
92 target[2] = m02;
93
94 target[3] = m10;
95 target[4] = m11;
96 target[5] = m12;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected