propane 2.7.2-java → 2.8.0.pre-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -0
  3. data/CHANGELOG.md +1 -1
  4. data/README.md +10 -8
  5. data/Rakefile +1 -1
  6. data/lib/propane/app.rb +3 -3
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{processing-core.jar → propane-2.8.0.jar} +0 -0
  9. data/library/control_panel/control_panel.rb +3 -2
  10. data/pom.rb +89 -88
  11. data/pom.xml +75 -46
  12. data/propane.gemspec +1 -2
  13. data/src/main/java/japplemenubar/JAppleMenuBar.java +88 -0
  14. data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  15. data/src/{monkstone → main/java/monkstone}/ColorUtil.java +0 -0
  16. data/src/{monkstone → main/java/monkstone}/MathToolModule.java +0 -0
  17. data/src/{monkstone → main/java/monkstone}/PropaneLibrary.java +0 -0
  18. data/src/{monkstone → main/java/monkstone}/core/LibraryProxy.java +0 -0
  19. data/src/{monkstone → main/java/monkstone}/fastmath/Deglut.java +0 -0
  20. data/src/{monkstone → main/java/monkstone}/fastmath/package-info.java +0 -0
  21. data/src/{monkstone → main/java/monkstone}/filechooser/Chooser.java +0 -0
  22. data/src/{monkstone → main/java/monkstone}/noise/SimplexNoise.java +0 -0
  23. data/src/{monkstone → main/java/monkstone}/slider/CustomHorizontalSlider.java +0 -0
  24. data/src/{monkstone → main/java/monkstone}/slider/CustomVerticalSlider.java +0 -0
  25. data/src/{monkstone → main/java/monkstone}/slider/SimpleHorizontalSlider.java +0 -0
  26. data/src/{monkstone → main/java/monkstone}/slider/SimpleSlider.java +0 -0
  27. data/src/{monkstone → main/java/monkstone}/slider/SimpleVerticalSlider.java +0 -0
  28. data/src/{monkstone → main/java/monkstone}/slider/Slider.java +0 -0
  29. data/src/{monkstone → main/java/monkstone}/slider/SliderBar.java +0 -0
  30. data/src/{monkstone → main/java/monkstone}/slider/SliderGroup.java +0 -0
  31. data/src/{monkstone → main/java/monkstone}/slider/WheelHandler.java +0 -0
  32. data/src/{monkstone → main/java/monkstone}/vecmath/AppRender.java +0 -0
  33. data/src/{monkstone → main/java/monkstone}/vecmath/JRender.java +0 -0
  34. data/src/{monkstone → main/java/monkstone}/vecmath/ShapeRender.java +0 -0
  35. data/src/{monkstone → main/java/monkstone}/vecmath/package-info.java +0 -0
  36. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/Vec2.java +0 -0
  37. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/package-info.java +0 -0
  38. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/Vec3.java +0 -0
  39. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/package-info.java +0 -0
  40. data/src/{monkstone → main/java/monkstone}/videoevent/VideoInterface.java +0 -0
  41. data/src/{monkstone → main/java/monkstone}/videoevent/package-info.java +0 -0
  42. data/src/main/java/processing/awt/PGraphicsJava2D.java +3029 -0
  43. data/src/main/java/processing/awt/PShapeJava2D.java +377 -0
  44. data/src/main/java/processing/awt/PSurfaceAWT.java +1567 -0
  45. data/src/main/java/processing/core/PApplet.java +15709 -0
  46. data/src/main/java/processing/core/PConstants.java +527 -0
  47. data/src/main/java/processing/core/PFont.java +1098 -0
  48. data/src/main/java/processing/core/PGraphics.java +8467 -0
  49. data/src/main/java/processing/core/PImage.java +3438 -0
  50. data/src/main/java/processing/core/PMatrix.java +208 -0
  51. data/src/main/java/processing/core/PMatrix2D.java +534 -0
  52. data/src/main/java/processing/core/PMatrix3D.java +877 -0
  53. data/src/main/java/processing/core/PShape.java +3445 -0
  54. data/src/main/java/processing/core/PShapeOBJ.java +469 -0
  55. data/src/main/java/processing/core/PShapeSVG.java +1787 -0
  56. data/src/main/java/processing/core/PStyle.java +63 -0
  57. data/src/main/java/processing/core/PSurface.java +161 -0
  58. data/src/main/java/processing/core/PSurfaceNone.java +374 -0
  59. data/src/main/java/processing/core/PVector.java +1063 -0
  60. data/src/main/java/processing/data/FloatDict.java +829 -0
  61. data/src/main/java/processing/data/FloatList.java +912 -0
  62. data/src/main/java/processing/data/IntDict.java +796 -0
  63. data/src/main/java/processing/data/IntList.java +913 -0
  64. data/src/main/java/processing/data/JSONArray.java +1260 -0
  65. data/src/main/java/processing/data/JSONObject.java +2282 -0
  66. data/src/main/java/processing/data/JSONTokener.java +435 -0
  67. data/src/main/java/processing/data/Sort.java +46 -0
  68. data/src/main/java/processing/data/StringDict.java +601 -0
  69. data/src/main/java/processing/data/StringList.java +775 -0
  70. data/src/main/java/processing/data/Table.java +4923 -0
  71. data/src/main/java/processing/data/TableRow.java +198 -0
  72. data/src/main/java/processing/data/XML.java +1149 -0
  73. data/src/main/java/processing/event/Event.java +125 -0
  74. data/src/main/java/processing/event/KeyEvent.java +70 -0
  75. data/src/main/java/processing/event/MouseEvent.java +149 -0
  76. data/src/main/java/processing/event/TouchEvent.java +57 -0
  77. data/src/main/java/processing/opengl/FontTexture.java +379 -0
  78. data/src/main/java/processing/opengl/FrameBuffer.java +503 -0
  79. data/src/main/java/processing/opengl/LinePath.java +623 -0
  80. data/src/main/java/processing/opengl/LineStroker.java +685 -0
  81. data/src/main/java/processing/opengl/PGL.java +3366 -0
  82. data/src/main/java/processing/opengl/PGraphics2D.java +615 -0
  83. data/src/main/java/processing/opengl/PGraphics3D.java +281 -0
  84. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13634 -0
  85. data/src/main/java/processing/opengl/PJOGL.java +1966 -0
  86. data/src/main/java/processing/opengl/PShader.java +1478 -0
  87. data/src/main/java/processing/opengl/PShapeOpenGL.java +5234 -0
  88. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1315 -0
  89. data/src/main/java/processing/opengl/Texture.java +1670 -0
  90. data/src/main/java/processing/opengl/VertexBuffer.java +88 -0
  91. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  92. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  93. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  94. data/src/main/java/processing/opengl/cursors/license.txt +27 -0
  95. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  96. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  97. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  98. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  99. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  100. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  101. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +154 -0
  102. data/src/main/java/processing/opengl/shaders/LightVert.glsl +151 -0
  103. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  104. data/src/main/java/processing/opengl/shaders/LineVert.glsl +100 -0
  105. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  106. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  107. data/src/main/java/processing/opengl/shaders/PointVert.glsl +56 -0
  108. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  109. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  110. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +160 -0
  111. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  112. data/src/main/java/processing/opengl/shaders/TexVert.glsl +38 -0
  113. data/src/main/resources/icon/icon-1024.png +0 -0
  114. data/src/main/resources/icon/icon-128.png +0 -0
  115. data/src/main/resources/icon/icon-16.png +0 -0
  116. data/src/main/resources/icon/icon-256.png +0 -0
  117. data/src/main/resources/icon/icon-32.png +0 -0
  118. data/src/main/resources/icon/icon-48.png +0 -0
  119. data/src/main/resources/icon/icon-512.png +0 -0
  120. data/src/main/resources/icon/icon-64.png +0 -0
  121. data/src/main/resources/license.txt +508 -0
  122. data/vendors/Rakefile +5 -20
  123. metadata +115 -33
  124. data/lib/propane.jar +0 -0
@@ -0,0 +1,534 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+ /*
4
+ Part of the Processing project - http://processing.org
5
+
6
+ Copyright (c) 2005-08 Ben Fry and Casey Reas
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation; either
11
+ version 2.1 of the License, or (at your option) any later version.
12
+
13
+ This library is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General
19
+ Public License along with this library; if not, write to the
20
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21
+ Boston, MA 02111-1307 USA
22
+ */
23
+
24
+ package processing.core;
25
+
26
+
27
+ /**
28
+ * 3x2 affine matrix implementation.
29
+ * Matrices are used to describe a transformation; see {@link PMatrix} for a
30
+ * general description. This matrix looks like the following when multiplying
31
+ * a vector (x, y) in {@code mult()}.
32
+ * <pre>
33
+ * [m00 m01 m02][x] [m00*x + m01*y + m02*1] [x']
34
+ * [m10 m11 m12][y] = [m10*x + m11*y + m12*1] = [y']
35
+ * [ 0 0 1 ][1] [ 0*x + 0*y + 1*1 ] [ 1]</pre>
36
+ * (x', y') is returned. The values in the matrix determine the transformation.
37
+ * They are modified by the various transformation functions.
38
+ */
39
+ public 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;
97
+
98
+ return target;
99
+ }
100
+
101
+
102
+ /**
103
+ * If matrix is a PMatrix2D, sets this matrix to be a copy of it.
104
+ * @throws IllegalArgumentException If <tt>matrix</tt> is not 2D.
105
+ */
106
+ public void set(PMatrix matrix) {
107
+ if (matrix instanceof PMatrix2D) {
108
+ PMatrix2D src = (PMatrix2D) matrix;
109
+ set(src.m00, src.m01, src.m02,
110
+ src.m10, src.m11, src.m12);
111
+ } else {
112
+ throw new IllegalArgumentException("PMatrix2D.set() only accepts PMatrix2D objects.");
113
+ }
114
+ }
115
+
116
+
117
+ /**
118
+ * Unavailable in 2D. Does nothing.
119
+ */
120
+ public void set(PMatrix3D src) {
121
+ }
122
+
123
+
124
+ public void set(float[] source) {
125
+ m00 = source[0];
126
+ m01 = source[1];
127
+ m02 = source[2];
128
+
129
+ m10 = source[3];
130
+ m11 = source[4];
131
+ m12 = source[5];
132
+ }
133
+
134
+
135
+ /**
136
+ * Sets the matrix content.
137
+ */
138
+ public void set(float m00, float m01, float m02,
139
+ float m10, float m11, float m12) {
140
+ this.m00 = m00; this.m01 = m01; this.m02 = m02;
141
+ this.m10 = m10; this.m11 = m11; this.m12 = m12;
142
+ }
143
+
144
+
145
+ /**
146
+ * Unavailable in 2D. Does nothing.
147
+ */
148
+ public void set(float m00, float m01, float m02, float m03,
149
+ float m10, float m11, float m12, float m13,
150
+ float m20, float m21, float m22, float m23,
151
+ float m30, float m31, float m32, float m33) {
152
+
153
+ }
154
+
155
+
156
+ public void translate(float tx, float ty) {
157
+ m02 = tx*m00 + ty*m01 + m02;
158
+ m12 = tx*m10 + ty*m11 + m12;
159
+ }
160
+
161
+
162
+ /**
163
+ * Unavailable in 2D.
164
+ * @throws IllegalArgumentException
165
+ */
166
+ public void translate(float x, float y, float z) {
167
+ throw new IllegalArgumentException("Cannot use translate(x, y, z) on a PMatrix2D.");
168
+ }
169
+
170
+
171
+ // Implementation roughly based on AffineTransform.
172
+ public void rotate(float angle) {
173
+ float s = sin(angle);
174
+ float c = cos(angle);
175
+
176
+ float temp1 = m00;
177
+ float temp2 = m01;
178
+ m00 = c * temp1 + s * temp2;
179
+ m01 = -s * temp1 + c * temp2;
180
+ temp1 = m10;
181
+ temp2 = m11;
182
+ m10 = c * temp1 + s * temp2;
183
+ m11 = -s * temp1 + c * temp2;
184
+ }
185
+
186
+
187
+ /**
188
+ * Unavailable in 2D.
189
+ * @throws IllegalArgumentException
190
+ */
191
+ public void rotateX(float angle) {
192
+ throw new IllegalArgumentException("Cannot use rotateX() on a PMatrix2D.");
193
+ }
194
+
195
+
196
+ /**
197
+ * Unavailable in 2D.
198
+ * @throws IllegalArgumentException
199
+ */
200
+ public void rotateY(float angle) {
201
+ throw new IllegalArgumentException("Cannot use rotateY() on a PMatrix2D.");
202
+ }
203
+
204
+
205
+ public void rotateZ(float angle) {
206
+ rotate(angle);
207
+ }
208
+
209
+
210
+ /**
211
+ * Unavailable in 2D.
212
+ * @throws IllegalArgumentException
213
+ */
214
+ public void rotate(float angle, float v0, float v1, float v2) {
215
+ throw new IllegalArgumentException("Cannot use this version of rotate() on a PMatrix2D.");
216
+ }
217
+
218
+
219
+ public void scale(float s) {
220
+ scale(s, s);
221
+ }
222
+
223
+
224
+ public void scale(float sx, float sy) {
225
+ m00 *= sx; m01 *= sy;
226
+ m10 *= sx; m11 *= sy;
227
+ }
228
+
229
+
230
+ /**
231
+ * Unavailable in 2D.
232
+ * @throws IllegalArgumentException
233
+ */
234
+ public void scale(float x, float y, float z) {
235
+ throw new IllegalArgumentException("Cannot use this version of scale() on a PMatrix2D.");
236
+ }
237
+
238
+
239
+ public void shearX(float angle) {
240
+ apply(1, 0, 1, tan(angle), 0, 0);
241
+ }
242
+
243
+
244
+ public void shearY(float angle) {
245
+ apply(1, 0, 1, 0, tan(angle), 0);
246
+ }
247
+
248
+
249
+ public void apply(PMatrix source) {
250
+ if (source instanceof PMatrix2D) {
251
+ apply((PMatrix2D) source);
252
+ } else if (source instanceof PMatrix3D) {
253
+ apply((PMatrix3D) source);
254
+ }
255
+ }
256
+
257
+
258
+ public void apply(PMatrix2D source) {
259
+ apply(source.m00, source.m01, source.m02,
260
+ source.m10, source.m11, source.m12);
261
+ }
262
+
263
+
264
+ /**
265
+ * Unavailable in 2D.
266
+ * @throws IllegalArgumentException
267
+ */
268
+ public void apply(PMatrix3D source) {
269
+ throw new IllegalArgumentException("Cannot use apply(PMatrix3D) on a PMatrix2D.");
270
+ }
271
+
272
+
273
+ public void apply(float n00, float n01, float n02,
274
+ float n10, float n11, float n12) {
275
+ float t0 = m00;
276
+ float t1 = m01;
277
+ m00 = n00 * t0 + n10 * t1;
278
+ m01 = n01 * t0 + n11 * t1;
279
+ m02 += n02 * t0 + n12 * t1;
280
+
281
+ t0 = m10;
282
+ t1 = m11;
283
+ m10 = n00 * t0 + n10 * t1;
284
+ m11 = n01 * t0 + n11 * t1;
285
+ m12 += n02 * t0 + n12 * t1;
286
+ }
287
+
288
+
289
+ /**
290
+ * Unavailable in 2D.
291
+ * @throws IllegalArgumentException
292
+ */
293
+ public void apply(float n00, float n01, float n02, float n03,
294
+ float n10, float n11, float n12, float n13,
295
+ float n20, float n21, float n22, float n23,
296
+ float n30, float n31, float n32, float n33) {
297
+ throw new IllegalArgumentException("Cannot use this version of apply() on a PMatrix2D.");
298
+ }
299
+
300
+
301
+ /**
302
+ * Apply another matrix to the left of this one.
303
+ */
304
+ public void preApply(PMatrix source) {
305
+ if (source instanceof PMatrix2D) {
306
+ preApply((PMatrix2D) source);
307
+ } else if (source instanceof PMatrix3D) {
308
+ preApply((PMatrix3D) source);
309
+ }
310
+ }
311
+
312
+
313
+ public void preApply(PMatrix2D left) {
314
+ preApply(left.m00, left.m01, left.m02,
315
+ left.m10, left.m11, left.m12);
316
+ }
317
+
318
+
319
+ /**
320
+ * Unavailable in 2D.
321
+ * @throws IllegalArgumentException
322
+ */
323
+ public void preApply(PMatrix3D left) {
324
+ throw new IllegalArgumentException("Cannot use preApply(PMatrix3D) on a PMatrix2D.");
325
+ }
326
+
327
+
328
+ public void preApply(float n00, float n01, float n02,
329
+ float n10, float n11, float n12) {
330
+ float t0 = m02;
331
+ float t1 = m12;
332
+ n02 += t0 * n00 + t1 * n01;
333
+ n12 += t0 * n10 + t1 * n11;
334
+
335
+ m02 = n02;
336
+ m12 = n12;
337
+
338
+ t0 = m00;
339
+ t1 = m10;
340
+ m00 = t0 * n00 + t1 * n01;
341
+ m10 = t0 * n10 + t1 * n11;
342
+
343
+ t0 = m01;
344
+ t1 = m11;
345
+ m01 = t0 * n00 + t1 * n01;
346
+ m11 = t0 * n10 + t1 * n11;
347
+ }
348
+
349
+
350
+ /**
351
+ * Unavailable in 2D.
352
+ * @throws IllegalArgumentException
353
+ */
354
+ public void preApply(float n00, float n01, float n02, float n03,
355
+ float n10, float n11, float n12, float n13,
356
+ float n20, float n21, float n22, float n23,
357
+ float n30, float n31, float n32, float n33) {
358
+ throw new IllegalArgumentException("Cannot use this version of preApply() on a PMatrix2D.");
359
+ }
360
+
361
+
362
+ //////////////////////////////////////////////////////////////
363
+
364
+
365
+ /**
366
+ * {@inheritDoc}
367
+ * Ignores any z component.
368
+ */
369
+ public PVector mult(PVector source, PVector target) {
370
+ if (target == null) {
371
+ target = new PVector();
372
+ }
373
+ target.x = m00*source.x + m01*source.y + m02;
374
+ target.y = m10*source.x + m11*source.y + m12;
375
+ return target;
376
+ }
377
+
378
+
379
+ /**
380
+ * Multiply a two element vector against this matrix.
381
+ * If out is null or not length four, a new float array will be returned.
382
+ * The values for vec and out can be the same (though that's less efficient).
383
+ */
384
+ public float[] mult(float vec[], float out[]) {
385
+ if (out == null || out.length != 2) {
386
+ out = new float[2];
387
+ }
388
+
389
+ if (vec == out) {
390
+ float tx = m00*vec[0] + m01*vec[1] + m02;
391
+ float ty = m10*vec[0] + m11*vec[1] + m12;
392
+
393
+ out[0] = tx;
394
+ out[1] = ty;
395
+
396
+ } else {
397
+ out[0] = m00*vec[0] + m01*vec[1] + m02;
398
+ out[1] = m10*vec[0] + m11*vec[1] + m12;
399
+ }
400
+
401
+ return out;
402
+ }
403
+
404
+
405
+ /**
406
+ * Returns the x-coordinate of the result of multiplying the point (x, y)
407
+ * by this matrix.
408
+ */
409
+ public float multX(float x, float y) {
410
+ return m00*x + m01*y + m02;
411
+ }
412
+
413
+
414
+ /**
415
+ * Returns the y-coordinate of the result of multiplying the point (x, y)
416
+ * by this matrix.
417
+ */
418
+ public float multY(float x, float y) {
419
+ return m10*x + m11*y + m12;
420
+ }
421
+
422
+
423
+
424
+ /**
425
+ * Unavailable in 2D. Does nothing.
426
+ */
427
+ public void transpose() {
428
+ }
429
+
430
+
431
+ /*
432
+ * Implementation stolen from OpenJDK.
433
+ */
434
+ public boolean invert() {
435
+ float determinant = determinant();
436
+ if (Math.abs(determinant) <= Float.MIN_VALUE) {
437
+ return false;
438
+ }
439
+
440
+ float t00 = m00;
441
+ float t01 = m01;
442
+ float t02 = m02;
443
+ float t10 = m10;
444
+ float t11 = m11;
445
+ float t12 = m12;
446
+
447
+ m00 = t11 / determinant;
448
+ m10 = -t10 / determinant;
449
+ m01 = -t01 / determinant;
450
+ m11 = t00 / determinant;
451
+ m02 = (t01 * t12 - t11 * t02) / determinant;
452
+ m12 = (t10 * t02 - t00 * t12) / determinant;
453
+
454
+ return true;
455
+ }
456
+
457
+
458
+ /**
459
+ * @return the determinant of the matrix
460
+ */
461
+ public float determinant() {
462
+ return m00 * m11 - m01 * m10;
463
+ }
464
+
465
+
466
+ //////////////////////////////////////////////////////////////
467
+
468
+
469
+ public void print() {
470
+ int big = (int) abs(max(PApplet.max(abs(m00), abs(m01), abs(m02)),
471
+ PApplet.max(abs(m10), abs(m11), abs(m12))));
472
+
473
+ int digits = 1;
474
+ if (Float.isNaN(big) || Float.isInfinite(big)) { // avoid infinite loop
475
+ digits = 5;
476
+ } else {
477
+ while ((big /= 10) != 0) digits++; // cheap log()
478
+ }
479
+
480
+ System.out.println(PApplet.nfs(m00, digits, 4) + " " +
481
+ PApplet.nfs(m01, digits, 4) + " " +
482
+ PApplet.nfs(m02, digits, 4));
483
+
484
+ System.out.println(PApplet.nfs(m10, digits, 4) + " " +
485
+ PApplet.nfs(m11, digits, 4) + " " +
486
+ PApplet.nfs(m12, digits, 4));
487
+
488
+ System.out.println();
489
+ }
490
+
491
+
492
+ //////////////////////////////////////////////////////////////
493
+
494
+ // TODO these need to be added as regular API, but the naming and
495
+ // implementation needs to be improved first. (e.g. actually keeping track
496
+ // of whether the matrix is in fact identity internally.)
497
+
498
+
499
+ protected boolean isIdentity() {
500
+ return ((m00 == 1) && (m01 == 0) && (m02 == 0) &&
501
+ (m10 == 0) && (m11 == 1) && (m12 == 0));
502
+ }
503
+
504
+
505
+ // TODO make this more efficient, or move into PMatrix2D
506
+ protected boolean isWarped() {
507
+ return ((m00 != 1) || (m01 != 0) &&
508
+ (m10 != 0) || (m11 != 1));
509
+ }
510
+
511
+
512
+ //////////////////////////////////////////////////////////////
513
+
514
+
515
+ static private final float max(float a, float b) {
516
+ return (a > b) ? a : b;
517
+ }
518
+
519
+ static private final float abs(float a) {
520
+ return (a < 0) ? -a : a;
521
+ }
522
+
523
+ static private final float sin(float angle) {
524
+ return (float)Math.sin(angle);
525
+ }
526
+
527
+ static private final float cos(float angle) {
528
+ return (float)Math.cos(angle);
529
+ }
530
+
531
+ static private final float tan(float angle) {
532
+ return (float)Math.tan(angle);
533
+ }
534
+ }