Skip to content

Commit 5fd9ed1

Browse files
committed
added preApply(PMatrix)
1 parent 081eaf6 commit 5fd9ed1

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

core/src/processing/core/PMatrix.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,30 +94,49 @@ public void apply(float n00, float n01, float n02, float n03,
9494
float n20, float n21, float n22, float n23,
9595
float n30, float n31, float n32, float n33);
9696

97+
/**
98+
* Apply another matrix to the left of this one.
99+
*/
100+
public void preApply(PMatrix left);
101+
97102
/**
98103
* Apply another matrix to the left of this one.
99104
*/
100105
public void preApply(PMatrix2D left);
101106

107+
/**
108+
* Apply another matrix to the left of this one. 3D only.
109+
*/
102110
public void preApply(PMatrix3D left);
103111

112+
/**
113+
* Apply another matrix to the left of this one.
114+
*/
104115
public void preApply(float n00, float n01, float n02,
105116
float n10, float n11, float n12);
106117

118+
/**
119+
* Apply another matrix to the left of this one. 3D only.
120+
*/
107121
public void preApply(float n00, float n01, float n02, float n03,
108122
float n10, float n11, float n12, float n13,
109123
float n20, float n21, float n22, float n23,
110124
float n30, float n31, float n32, float n33);
111125

112126

113127
/**
114-
* Multiply a PVector by this matrix.
128+
* Multiply source by this matrix, and return the result.
129+
* The result will be stored in target if target is non-null, and target
130+
* will then be the matrix returned. This improves performance if you reuse
131+
* target, so it's recommended if you call this many times in draw().
115132
*/
116133
public PVector mult(PVector source, PVector target);
117134

118135

119136
/**
120137
* Multiply a multi-element vector against this matrix.
138+
* Supplying and recycling a target array improves performance, so it's
139+
* recommended if you call this many times in draw().
121140
*/
122141
public float[] mult(float[] source, float[] target);
123142

@@ -131,13 +150,14 @@ public void preApply(float n00, float n01, float n02, float n03,
131150

132151

133152
/**
134-
* Transpose this matrix.
153+
* Transpose this matrix; rows become columns and columns rows.
135154
*/
136155
public void transpose();
137156

138157

139158
/**
140-
* Invert this matrix.
159+
* Invert this matrix. Will not necessarily succeed, because some matrices
160+
* map more than one point to the same image point, and so are irreversible.
141161
* @return true if successful
142162
*/
143163
public boolean invert();

core/src/processing/core/PMatrix2D.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,18 @@ public void apply(float n00, float n01, float n02, float n03,
244244
}
245245

246246

247+
/**
248+
* Apply another matrix to the left of this one.
249+
*/
250+
public void preApply(PMatrix source) {
251+
if (source instanceof PMatrix2D) {
252+
preApply((PMatrix2D) source);
253+
} else if (source instanceof PMatrix3D) {
254+
preApply((PMatrix3D) source);
255+
}
256+
}
257+
258+
247259
/**
248260
* Apply another matrix to the left of this one.
249261
*/

core/src/processing/core/PMatrix3D.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,18 @@ public void apply(float n00, float n01, float n02, float n03,
359359
}
360360

361361

362+
/**
363+
* Apply another matrix to the left of this one.
364+
*/
365+
public void preApply(PMatrix source) {
366+
if (source instanceof PMatrix2D) {
367+
preApply((PMatrix2D) source);
368+
} else if (source instanceof PMatrix3D) {
369+
preApply((PMatrix3D) source);
370+
}
371+
}
372+
373+
362374
public void preApply(PMatrix2D left) {
363375
preApply(left.m00, left.m01, 0, left.m02,
364376
left.m10, left.m11, 0, left.m12,

0 commit comments

Comments
 (0)