@@ -38,20 +38,20 @@ public PMatrix2D() {
3838 }
3939
4040
41- public PMatrix2D (float m00 , float m01 , float m02 ,
41+ public PMatrix2D (float m00 , float m01 , float m02 ,
4242 float m10 , float m11 , float m12 ) {
4343 set (m00 , m01 , m02 ,
4444 m10 , m11 , m12 );
4545 }
46-
47-
46+
47+
4848 public PMatrix2D (PMatrix matrix ) {
4949 set (matrix );
5050 }
51-
51+
5252
5353 public void reset () {
54- set (1 , 0 , 0 ,
54+ set (1 , 0 , 0 ,
5555 0 , 1 , 0 );
5656 }
5757
@@ -64,8 +64,8 @@ public PMatrix2D get() {
6464 outgoing .set (this );
6565 return outgoing ;
6666 }
67-
68-
67+
68+
6969 /**
7070 * Copies the matrix contents into a 6 entry float array.
7171 * If target is null (or not the correct size), a new array will be created.
@@ -77,14 +77,14 @@ public float[] get(float[] target) {
7777 target [0 ] = m00 ;
7878 target [1 ] = m01 ;
7979 target [2 ] = m02 ;
80-
80+
8181 target [3 ] = m10 ;
8282 target [4 ] = m11 ;
8383 target [5 ] = m12 ;
8484
8585 return target ;
8686 }
87-
87+
8888
8989 public void set (PMatrix matrix ) {
9090 if (matrix instanceof PMatrix2D ) {
@@ -95,8 +95,8 @@ public void set(PMatrix matrix) {
9595 throw new IllegalArgumentException ("PMatrix2D.set() only accepts PMatrix2D objects." );
9696 }
9797 }
98-
99-
98+
99+
100100 public void set (PMatrix3D src ) {
101101 }
102102
@@ -110,34 +110,34 @@ public void set(float[] source) {
110110 m11 = source [4 ];
111111 m12 = source [5 ];
112112 }
113-
114-
115- public void set (float m00 , float m01 , float m02 ,
113+
114+
115+ public void set (float m00 , float m01 , float m02 ,
116116 float m10 , float m11 , float m12 ) {
117- this .m00 = m00 ; this .m01 = m01 ; this .m02 = m02 ;
117+ this .m00 = m00 ; this .m01 = m01 ; this .m02 = m02 ;
118118 this .m10 = m10 ; this .m11 = m11 ; this .m12 = m12 ;
119119 }
120-
121-
120+
121+
122122 public void set (float m00 , float m01 , float m02 , float m03 ,
123123 float m10 , float m11 , float m12 , float m13 ,
124124 float m20 , float m21 , float m22 , float m23 ,
125125 float m30 , float m31 , float m32 , float m33 ) {
126-
126+
127127 }
128128
129129
130- public void translate (float tx , float ty ) {
130+ public void translate (float tx , float ty ) {
131131 m02 = tx *m00 + ty *m01 + m02 ;
132132 m12 = tx *m10 + ty *m11 + m12 ;
133133 }
134-
135-
134+
135+
136136 public void translate (float x , float y , float z ) {
137137 throw new IllegalArgumentException ("Cannot use translate(x, y, z) on a PMatrix2D." );
138138 }
139139
140-
140+
141141 // Implementation roughly based on AffineTransform.
142142 public void rotate (float angle ) {
143143 float s = sin (angle );
@@ -180,8 +180,8 @@ public void scale(float s) {
180180
181181
182182 public void scale (float sx , float sy ) {
183- m00 *= sx ; m01 *= sy ;
184- m10 *= sx ; m11 *= sy ;
183+ m00 *= sx ; m01 *= sy ;
184+ m10 *= sx ; m11 *= sy ;
185185 }
186186
187187
@@ -190,27 +190,37 @@ public void scale(float x, float y, float z) {
190190 }
191191
192192
193+ public void skewX (float angle ) {
194+ apply (1 , 0 , 1 , angle , 0 , 0 );
195+ }
196+
197+
198+ public void skewY (float angle ) {
199+ apply (1 , 0 , 1 , 0 , angle , 0 );
200+ }
201+
202+
193203 public void apply (PMatrix source ) {
194204 if (source instanceof PMatrix2D ) {
195205 apply ((PMatrix2D ) source );
196206 } else if (source instanceof PMatrix3D ) {
197207 apply ((PMatrix3D ) source );
198208 }
199209 }
200-
210+
201211
202212 public void apply (PMatrix2D source ) {
203- apply (source .m00 , source .m01 , source .m02 ,
213+ apply (source .m00 , source .m01 , source .m02 ,
204214 source .m10 , source .m11 , source .m12 );
205215 }
206-
207-
216+
217+
208218 public void apply (PMatrix3D source ) {
209219 throw new IllegalArgumentException ("Cannot use apply(PMatrix3D) on a PMatrix2D." );
210220 }
211-
212-
213- public void apply (float n00 , float n01 , float n02 ,
221+
222+
223+ public void apply (float n00 , float n01 , float n02 ,
214224 float n10 , float n11 , float n12 ) {
215225 float t0 = m00 ;
216226 float t1 = m01 ;
@@ -222,7 +232,7 @@ public void apply(float n00, float n01, float n02,
222232 t1 = m11 ;
223233 m10 = n00 * t0 + n10 * t1 ;
224234 m11 = n01 * t0 + n11 * t1 ;
225- m12 += n02 * t0 + n12 * t1 ;
235+ m12 += n02 * t0 + n12 * t1 ;
226236 }
227237
228238
@@ -241,8 +251,8 @@ public void preApply(PMatrix2D left) {
241251 preApply (left .m00 , left .m01 , left .m02 ,
242252 left .m10 , left .m11 , left .m12 );
243253 }
244-
245-
254+
255+
246256 public void preApply (PMatrix3D left ) {
247257 throw new IllegalArgumentException ("Cannot use preApply(PMatrix3D) on a PMatrix2D." );
248258 }
@@ -266,7 +276,7 @@ public void preApply(float n00, float n01, float n02,
266276 t0 = m01 ;
267277 t1 = m11 ;
268278 m01 = t0 * n00 + t1 * n01 ;
269- m11 = t0 * n10 + t1 * n11 ;
279+ m11 = t0 * n10 + t1 * n11 ;
270280 }
271281
272282
@@ -293,17 +303,17 @@ public PVector mult(PVector source, PVector target) {
293303 return target ;
294304 }
295305
296-
297- /**
298- * Multiply a two element vector against this matrix.
306+
307+ /**
308+ * Multiply a two element vector against this matrix.
299309 * If out is null or not length four, a new float array will be returned.
300- * The values for vec and out can be the same (though that's less efficient).
310+ * The values for vec and out can be the same (though that's less efficient).
301311 */
302312 public float [] mult (float vec [], float out []) {
303313 if (out == null || out .length != 2 ) {
304314 out = new float [2 ];
305315 }
306-
316+
307317 if (vec == out ) {
308318 float tx = m00 *vec [0 ] + m01 *vec [1 ] + m02 ;
309319 float ty = m10 *vec [0 ] + m11 *vec [1 ] + m12 ;
@@ -315,21 +325,21 @@ public float[] mult(float vec[], float out[]) {
315325 out [0 ] = m00 *vec [0 ] + m01 *vec [1 ] + m02 ;
316326 out [1 ] = m10 *vec [0 ] + m11 *vec [1 ] + m12 ;
317327 }
318-
328+
319329 return out ;
320330 }
321-
322-
331+
332+
323333 public float multX (float x , float y ) {
324334 return m00 *x + m01 *y + m02 ;
325335 }
326-
327-
336+
337+
328338 public float multY (float x , float y ) {
329339 return m10 *x + m11 *y + m12 ;
330340 }
331-
332-
341+
342+
333343 /**
334344 * Transpose this matrix.
335345 */
@@ -346,33 +356,33 @@ public boolean invert() {
346356 if (Math .abs (determinant ) <= Float .MIN_VALUE ) {
347357 return false ;
348358 }
349-
350- float t00 = m00 ;
351- float t01 = m01 ;
359+
360+ float t00 = m00 ;
361+ float t01 = m01 ;
352362 float t02 = m02 ;
353- float t10 = m10 ;
354- float t11 = m11 ;
363+ float t10 = m10 ;
364+ float t11 = m11 ;
355365 float t12 = m12 ;
356366
357367 m00 = t11 / determinant ;
358368 m10 = -t10 / determinant ;
359369 m01 = -t01 / determinant ;
360370 m11 = t00 / determinant ;
361371 m02 = (t01 * t12 - t11 * t02 ) / determinant ;
362- m12 = (t10 * t02 - t00 * t12 ) / determinant ;
363-
372+ m12 = (t10 * t02 - t00 * t12 ) / determinant ;
373+
364374 return true ;
365375 }
366-
367-
376+
377+
368378 /**
369379 * @return the determinant of the matrix
370380 */
371381 public float determinant () {
372382 return m00 * m11 - m01 * m10 ;
373383 }
374384
375-
385+
376386 //////////////////////////////////////////////////////////////
377387
378388
0 commit comments