propane 3.9.0-java → 3.10.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +2 -2
  4. data/README.md +3 -3
  5. data/Rakefile +6 -6
  6. data/lib/java/japplemenubar/JAppleMenuBar.java +88 -0
  7. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  8. data/lib/java/monkstone/ColorUtil.java +127 -0
  9. data/lib/java/monkstone/MathToolModule.java +287 -0
  10. data/lib/java/monkstone/PropaneLibrary.java +46 -0
  11. data/lib/java/monkstone/core/LibraryProxy.java +136 -0
  12. data/lib/java/monkstone/fastmath/DegLutTables.java +111 -0
  13. data/lib/java/monkstone/fastmath/Deglut.java +71 -0
  14. data/lib/java/monkstone/fastmath/package-info.java +6 -0
  15. data/lib/java/monkstone/filechooser/Chooser.java +39 -0
  16. data/{src/main → lib}/java/monkstone/noise/FastTerrain.java +0 -0
  17. data/{src/main → lib}/java/monkstone/noise/Noise.java +0 -0
  18. data/{src/main → lib}/java/monkstone/noise/NoiseGenerator.java +0 -0
  19. data/{src/main → lib}/java/monkstone/noise/NoiseMode.java +0 -0
  20. data/lib/java/monkstone/noise/OpenSimplex2F.java +881 -0
  21. data/lib/java/monkstone/noise/OpenSimplex2S.java +1106 -0
  22. data/{src/main → lib}/java/monkstone/noise/SmoothTerrain.java +0 -0
  23. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +164 -0
  24. data/lib/java/monkstone/slider/CustomVerticalSlider.java +178 -0
  25. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +145 -0
  26. data/lib/java/monkstone/slider/SimpleSlider.java +166 -0
  27. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +157 -0
  28. data/lib/java/monkstone/slider/Slider.java +61 -0
  29. data/lib/java/monkstone/slider/SliderBar.java +245 -0
  30. data/lib/java/monkstone/slider/SliderGroup.java +56 -0
  31. data/lib/java/monkstone/slider/WheelHandler.java +35 -0
  32. data/lib/java/monkstone/vecmath/GfxRender.java +86 -0
  33. data/lib/java/monkstone/vecmath/JRender.java +56 -0
  34. data/lib/java/monkstone/vecmath/ShapeRender.java +87 -0
  35. data/lib/java/monkstone/vecmath/package-info.java +20 -0
  36. data/lib/java/monkstone/vecmath/vec2/Vec2.java +802 -0
  37. data/lib/java/monkstone/vecmath/vec2/package-info.java +6 -0
  38. data/lib/java/monkstone/vecmath/vec3/Vec3.java +727 -0
  39. data/lib/java/monkstone/vecmath/vec3/package-info.java +6 -0
  40. data/lib/java/monkstone/videoevent/CaptureEvent.java +27 -0
  41. data/lib/java/monkstone/videoevent/MovieEvent.java +32 -0
  42. data/lib/java/monkstone/videoevent/package-info.java +20 -0
  43. data/lib/java/processing/awt/PGraphicsJava2D.java +3040 -0
  44. data/lib/java/processing/awt/PImageAWT.java +377 -0
  45. data/lib/java/processing/awt/PShapeJava2D.java +387 -0
  46. data/lib/java/processing/awt/PSurfaceAWT.java +1581 -0
  47. data/lib/java/processing/awt/ShimAWT.java +581 -0
  48. data/lib/java/processing/core/PApplet.java +15156 -0
  49. data/lib/java/processing/core/PConstants.java +523 -0
  50. data/lib/java/processing/core/PFont.java +1126 -0
  51. data/lib/java/processing/core/PGraphics.java +8600 -0
  52. data/lib/java/processing/core/PImage.java +3377 -0
  53. data/lib/java/processing/core/PMatrix.java +208 -0
  54. data/lib/java/processing/core/PMatrix2D.java +562 -0
  55. data/lib/java/processing/core/PMatrix3D.java +890 -0
  56. data/lib/java/processing/core/PShape.java +3561 -0
  57. data/lib/java/processing/core/PShapeOBJ.java +483 -0
  58. data/lib/java/processing/core/PShapeSVG.java +2016 -0
  59. data/lib/java/processing/core/PStyle.java +63 -0
  60. data/lib/java/processing/core/PSurface.java +198 -0
  61. data/lib/java/processing/core/PSurfaceNone.java +431 -0
  62. data/lib/java/processing/core/PVector.java +1066 -0
  63. data/lib/java/processing/core/ThinkDifferent.java +115 -0
  64. data/lib/java/processing/data/DoubleDict.java +850 -0
  65. data/lib/java/processing/data/DoubleList.java +928 -0
  66. data/lib/java/processing/data/FloatDict.java +847 -0
  67. data/lib/java/processing/data/FloatList.java +936 -0
  68. data/lib/java/processing/data/IntDict.java +807 -0
  69. data/lib/java/processing/data/IntList.java +936 -0
  70. data/lib/java/processing/data/JSONArray.java +1260 -0
  71. data/lib/java/processing/data/JSONObject.java +2282 -0
  72. data/lib/java/processing/data/JSONTokener.java +435 -0
  73. data/lib/java/processing/data/LongDict.java +802 -0
  74. data/lib/java/processing/data/LongList.java +937 -0
  75. data/lib/java/processing/data/Sort.java +46 -0
  76. data/lib/java/processing/data/StringDict.java +613 -0
  77. data/lib/java/processing/data/StringList.java +800 -0
  78. data/lib/java/processing/data/Table.java +4936 -0
  79. data/lib/java/processing/data/TableRow.java +198 -0
  80. data/lib/java/processing/data/XML.java +1156 -0
  81. data/lib/java/processing/dxf/RawDXF.java +404 -0
  82. data/lib/java/processing/event/Event.java +125 -0
  83. data/lib/java/processing/event/KeyEvent.java +70 -0
  84. data/lib/java/processing/event/MouseEvent.java +114 -0
  85. data/lib/java/processing/event/TouchEvent.java +57 -0
  86. data/lib/java/processing/javafx/PGraphicsFX2D.java +32 -0
  87. data/lib/java/processing/javafx/PSurfaceFX.java +173 -0
  88. data/lib/java/processing/net/Client.java +744 -0
  89. data/lib/java/processing/net/Server.java +388 -0
  90. data/lib/java/processing/opengl/FontTexture.java +378 -0
  91. data/lib/java/processing/opengl/FrameBuffer.java +513 -0
  92. data/lib/java/processing/opengl/LinePath.java +627 -0
  93. data/lib/java/processing/opengl/LineStroker.java +681 -0
  94. data/lib/java/processing/opengl/PGL.java +3483 -0
  95. data/lib/java/processing/opengl/PGraphics2D.java +615 -0
  96. data/lib/java/processing/opengl/PGraphics3D.java +281 -0
  97. data/lib/java/processing/opengl/PGraphicsOpenGL.java +13753 -0
  98. data/lib/java/processing/opengl/PJOGL.java +2008 -0
  99. data/lib/java/processing/opengl/PShader.java +1484 -0
  100. data/lib/java/processing/opengl/PShapeOpenGL.java +5269 -0
  101. data/lib/java/processing/opengl/PSurfaceJOGL.java +1385 -0
  102. data/lib/java/processing/opengl/Texture.java +1696 -0
  103. data/lib/java/processing/opengl/VertexBuffer.java +88 -0
  104. data/lib/java/processing/opengl/cursors/arrow.png +0 -0
  105. data/lib/java/processing/opengl/cursors/cross.png +0 -0
  106. data/lib/java/processing/opengl/cursors/hand.png +0 -0
  107. data/lib/java/processing/opengl/cursors/license.txt +27 -0
  108. data/lib/java/processing/opengl/cursors/move.png +0 -0
  109. data/lib/java/processing/opengl/cursors/text.png +0 -0
  110. data/lib/java/processing/opengl/cursors/wait.png +0 -0
  111. data/lib/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  112. data/lib/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  113. data/lib/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  114. data/lib/java/processing/opengl/shaders/LightVert.glsl +151 -0
  115. data/lib/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  116. data/lib/java/processing/opengl/shaders/LineVert.glsl +100 -0
  117. data/lib/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  118. data/lib/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  119. data/lib/java/processing/opengl/shaders/PointVert.glsl +56 -0
  120. data/lib/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  121. data/lib/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  122. data/lib/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  123. data/lib/java/processing/opengl/shaders/TexVert.glsl +38 -0
  124. data/lib/java/processing/pdf/PGraphicsPDF.java +581 -0
  125. data/lib/java/processing/svg/PGraphicsSVG.java +378 -0
  126. data/lib/propane/app.rb +8 -13
  127. data/lib/propane/version.rb +1 -1
  128. data/mvnw +3 -3
  129. data/mvnw.cmd +2 -2
  130. data/pom.rb +7 -2
  131. data/pom.xml +14 -2
  132. data/propane.gemspec +2 -2
  133. data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
  134. data/src/main/java/monkstone/MathToolModule.java +30 -30
  135. data/src/main/java/monkstone/PropaneLibrary.java +2 -0
  136. data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
  137. data/src/main/java/monkstone/fastmath/DegLutTables.java +15 -15
  138. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  139. data/src/main/java/monkstone/noise/OpenSimplex2F.java +752 -820
  140. data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -1106
  141. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  142. data/src/main/java/monkstone/vecmath/JRender.java +6 -6
  143. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +20 -19
  144. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +12 -12
  145. data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -3
  146. data/src/main/java/processing/core/PApplet.java +89 -89
  147. data/src/main/java/processing/core/PConstants.java +155 -163
  148. data/src/main/java/processing/opengl/PJOGL.java +6 -5
  149. data/vendors/Rakefile +1 -1
  150. metadata +136 -19
@@ -0,0 +1,208 @@
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
+ * A matrix is used to define graphical transformations. PMatrix is the common
29
+ * interface for both the 2D and 3D matrix classes in Processing. A matrix is a
30
+ * grid of numbers, which can be multiplied by a vector to give another vector.
31
+ * Multiplying a point by a particular matrix might translate it, rotate it,
32
+ * or carry out a combination of transformations.
33
+ *
34
+ * Multiplying matrices by each other combines their effects; use the
35
+ * {@code apply} and {@code preApply} methods for this.
36
+ */
37
+ public interface PMatrix {
38
+
39
+ /**
40
+ * Make this an identity matrix. Multiplying by it will have no effect.
41
+ */
42
+ public void reset();
43
+
44
+ /**
45
+ * Returns a copy of this PMatrix.
46
+ */
47
+ public PMatrix get();
48
+
49
+ /**
50
+ * Copies the matrix contents into a float array.
51
+ * If target is null (or not the correct size), a new array will be created.
52
+ */
53
+ public float[] get(float[] target);
54
+
55
+
56
+ /**
57
+ * Make this matrix become a copy of src.
58
+ */
59
+ public void set(PMatrix src);
60
+
61
+ /**
62
+ * Set the contents of this matrix to the contents of source. Fills the
63
+ * matrix left-to-right, starting in the top row.
64
+ */
65
+ public void set(float[] source);
66
+
67
+ /**
68
+ * Set the matrix content to this 2D matrix or its 3D equivalent.
69
+ */
70
+ public void set(float m00, float m01, float m02,
71
+ float m10, float m11, float m12);
72
+
73
+ /**
74
+ * Set the matrix content to the 3D matrix supplied, if this matrix is 3D.
75
+ */
76
+ public void set(float m00, float m01, float m02, float m03,
77
+ float m10, float m11, float m12, float m13,
78
+ float m20, float m21, float m22, float m23,
79
+ float m30, float m31, float m32, float m33);
80
+
81
+
82
+ public void translate(float tx, float ty);
83
+
84
+ public void translate(float tx, float ty, float tz);
85
+
86
+ public void rotate(float angle);
87
+
88
+ public void rotateX(float angle);
89
+
90
+ public void rotateY(float angle);
91
+
92
+ public void rotateZ(float angle);
93
+
94
+ public void rotate(float angle, float v0, float v1, float v2);
95
+
96
+ public void scale(float s);
97
+
98
+ public void scale(float sx, float sy);
99
+
100
+ public void scale(float x, float y, float z);
101
+
102
+ public void shearX(float angle);
103
+
104
+ public void shearY(float angle);
105
+
106
+ /**
107
+ * Multiply this matrix by another.
108
+ */
109
+ public void apply(PMatrix source);
110
+
111
+ /**
112
+ * Multiply this matrix by another.
113
+ */
114
+ public void apply(PMatrix2D source);
115
+
116
+ /**
117
+ * Multiply this matrix by another.
118
+ */
119
+ public void apply(PMatrix3D source);
120
+
121
+ /**
122
+ * Multiply this matrix by another.
123
+ */
124
+ public void apply(float n00, float n01, float n02,
125
+ float n10, float n11, float n12);
126
+
127
+ /**
128
+ * Multiply this matrix by another.
129
+ */
130
+ public void apply(float n00, float n01, float n02, float n03,
131
+ float n10, float n11, float n12, float n13,
132
+ float n20, float n21, float n22, float n23,
133
+ float n30, float n31, float n32, float n33);
134
+
135
+ /**
136
+ * Apply another matrix to the left of this one.
137
+ */
138
+ public void preApply(PMatrix left);
139
+
140
+ /**
141
+ * Apply another matrix to the left of this one.
142
+ */
143
+ public void preApply(PMatrix2D left);
144
+
145
+ /**
146
+ * Apply another matrix to the left of this one. 3D only.
147
+ */
148
+ public void preApply(PMatrix3D left);
149
+
150
+ /**
151
+ * Apply another matrix to the left of this one.
152
+ */
153
+ public void preApply(float n00, float n01, float n02,
154
+ float n10, float n11, float n12);
155
+
156
+ /**
157
+ * Apply another matrix to the left of this one. 3D only.
158
+ */
159
+ public void preApply(float n00, float n01, float n02, float n03,
160
+ float n10, float n11, float n12, float n13,
161
+ float n20, float n21, float n22, float n23,
162
+ float n30, float n31, float n32, float n33);
163
+
164
+
165
+ /**
166
+ * Multiply source by this matrix, and return the result.
167
+ * The result will be stored in target if target is non-null, and target
168
+ * will then be the matrix returned. This improves performance if you reuse
169
+ * target, so it's recommended if you call this many times in draw().
170
+ */
171
+ public PVector mult(PVector source, PVector target);
172
+
173
+
174
+ /**
175
+ * Multiply a multi-element vector against this matrix.
176
+ * Supplying and recycling a target array improves performance, so it's
177
+ * recommended if you call this many times in draw().
178
+ */
179
+ public float[] mult(float[] source, float[] target);
180
+
181
+
182
+ // public float multX(float x, float y);
183
+ // public float multY(float x, float y);
184
+
185
+ // public float multX(float x, float y, float z);
186
+ // public float multY(float x, float y, float z);
187
+ // public float multZ(float x, float y, float z);
188
+
189
+
190
+ /**
191
+ * Transpose this matrix; rows become columns and columns rows.
192
+ */
193
+ public void transpose();
194
+
195
+
196
+ /**
197
+ * Invert this matrix. Will not necessarily succeed, because some matrices
198
+ * map more than one point to the same image point, and so are irreversible.
199
+ * @return true if successful
200
+ */
201
+ public boolean invert();
202
+
203
+
204
+ /**
205
+ * @return the determinant of the matrix
206
+ */
207
+ public float determinant();
208
+ }
@@ -0,0 +1,562 @@
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
+ @Override
66
+ public void reset() {
67
+ set(1, 0, 0,
68
+ 0, 1, 0);
69
+ }
70
+
71
+
72
+ /**
73
+ * Returns a copy of this PMatrix.
74
+ */
75
+ @Override
76
+ public PMatrix2D get() {
77
+ PMatrix2D outgoing = new PMatrix2D();
78
+ outgoing.set(this);
79
+ return outgoing;
80
+ }
81
+
82
+
83
+ /**
84
+ * Copies the matrix contents into a 6 entry float array.
85
+ * If target is null (or not the correct size), a new array will be created.
86
+ * Returned in the order {@code {m00, m01, m02, m10, m11, m12}}.
87
+ */
88
+ @Override
89
+ public float[] get(float[] target) {
90
+ if ((target == null) || (target.length != 6)) {
91
+ target = new float[6];
92
+ }
93
+ target[0] = m00;
94
+ target[1] = m01;
95
+ target[2] = m02;
96
+
97
+ target[3] = m10;
98
+ target[4] = m11;
99
+ target[5] = m12;
100
+
101
+ return target;
102
+ }
103
+
104
+
105
+ /**
106
+ * If matrix is a PMatrix2D, sets this matrix to be a copy of it.
107
+ * @throws IllegalArgumentException If <tt>matrix</tt> is not 2D.
108
+ */
109
+ public void set(PMatrix matrix) {
110
+ if (matrix instanceof PMatrix2D) {
111
+ PMatrix2D src = (PMatrix2D) matrix;
112
+ set(src.m00, src.m01, src.m02,
113
+ src.m10, src.m11, src.m12);
114
+ } else {
115
+ throw new IllegalArgumentException("PMatrix2D.set() only accepts PMatrix2D objects.");
116
+ }
117
+ }
118
+
119
+
120
+ /**
121
+ * Unavailable in 2D. Does nothing.
122
+ */
123
+ public void set(PMatrix3D src) {
124
+ }
125
+
126
+
127
+ @Override
128
+ public void set(float[] source) {
129
+ m00 = source[0];
130
+ m01 = source[1];
131
+ m02 = source[2];
132
+
133
+ m10 = source[3];
134
+ m11 = source[4];
135
+ m12 = source[5];
136
+ }
137
+
138
+
139
+ /**
140
+ * Sets the matrix content.
141
+ */
142
+ @Override
143
+ public void set(float m00, float m01, float m02,
144
+ float m10, float m11, float m12) {
145
+ this.m00 = m00; this.m01 = m01; this.m02 = m02;
146
+ this.m10 = m10; this.m11 = m11; this.m12 = m12;
147
+ }
148
+
149
+
150
+ /**
151
+ * Unavailable in 2D. Does nothing.
152
+ */
153
+ public void set(float m00, float m01, float m02, float m03,
154
+ float m10, float m11, float m12, float m13,
155
+ float m20, float m21, float m22, float m23,
156
+ float m30, float m31, float m32, float m33) {
157
+
158
+ }
159
+
160
+
161
+ @Override
162
+ public void translate(float tx, float ty) {
163
+ m02 = tx*m00 + ty*m01 + m02;
164
+ m12 = tx*m10 + ty*m11 + m12;
165
+ }
166
+
167
+
168
+ /**
169
+ * Unavailable in 2D.
170
+ * @throws IllegalArgumentException
171
+ */
172
+ @Override
173
+ public void translate(float x, float y, float z) {
174
+ throw new IllegalArgumentException("Cannot use translate(x, y, z) on a PMatrix2D.");
175
+ }
176
+
177
+
178
+ // Implementation roughly based on AffineTransform.
179
+ @Override
180
+ public void rotate(float angle) {
181
+ float s = sin(angle);
182
+ float c = cos(angle);
183
+
184
+ float temp1 = m00;
185
+ float temp2 = m01;
186
+ m00 = c * temp1 + s * temp2;
187
+ m01 = -s * temp1 + c * temp2;
188
+ temp1 = m10;
189
+ temp2 = m11;
190
+ m10 = c * temp1 + s * temp2;
191
+ m11 = -s * temp1 + c * temp2;
192
+ }
193
+
194
+
195
+ /**
196
+ * Unavailable in 2D.
197
+ * @throws IllegalArgumentException
198
+ */
199
+ @Override
200
+ public void rotateX(float angle) {
201
+ throw new IllegalArgumentException("Cannot use rotateX() on a PMatrix2D.");
202
+ }
203
+
204
+
205
+ /**
206
+ * Unavailable in 2D.
207
+ * @throws IllegalArgumentException
208
+ */
209
+ @Override
210
+ public void rotateY(float angle) {
211
+ throw new IllegalArgumentException("Cannot use rotateY() on a PMatrix2D.");
212
+ }
213
+
214
+
215
+ @Override
216
+ public void rotateZ(float angle) {
217
+ rotate(angle);
218
+ }
219
+
220
+
221
+ /**
222
+ * Unavailable in 2D.
223
+ * @throws IllegalArgumentException
224
+ */
225
+ @Override
226
+ public void rotate(float angle, float v0, float v1, float v2) {
227
+ throw new IllegalArgumentException("Cannot use this version of rotate() on a PMatrix2D.");
228
+ }
229
+
230
+
231
+ @Override
232
+ public void scale(float s) {
233
+ scale(s, s);
234
+ }
235
+
236
+
237
+ @Override
238
+ public void scale(float sx, float sy) {
239
+ m00 *= sx; m01 *= sy;
240
+ m10 *= sx; m11 *= sy;
241
+ }
242
+
243
+
244
+ /**
245
+ * Unavailable in 2D.
246
+ * @throws IllegalArgumentException
247
+ */
248
+ @Override
249
+ public void scale(float x, float y, float z) {
250
+ throw new IllegalArgumentException("Cannot use this version of scale() on a PMatrix2D.");
251
+ }
252
+
253
+
254
+ @Override
255
+ public void shearX(float angle) {
256
+ apply(1, 0, 1, tan(angle), 0, 0);
257
+ }
258
+
259
+
260
+ @Override
261
+ public void shearY(float angle) {
262
+ apply(1, 0, 1, 0, tan(angle), 0);
263
+ }
264
+
265
+
266
+ @Override
267
+ public void apply(PMatrix source) {
268
+ if (source instanceof PMatrix2D) {
269
+ apply((PMatrix2D) source);
270
+ } else if (source instanceof PMatrix3D) {
271
+ apply((PMatrix3D) source);
272
+ }
273
+ }
274
+
275
+
276
+ @Override
277
+ public void apply(PMatrix2D source) {
278
+ apply(source.m00, source.m01, source.m02,
279
+ source.m10, source.m11, source.m12);
280
+ }
281
+
282
+
283
+ /**
284
+ * Unavailable in 2D.
285
+ * @throws IllegalArgumentException
286
+ */
287
+ @Override
288
+ public void apply(PMatrix3D source) {
289
+ throw new IllegalArgumentException("Cannot use apply(PMatrix3D) on a PMatrix2D.");
290
+ }
291
+
292
+
293
+ @Override
294
+ public void apply(float n00, float n01, float n02,
295
+ float n10, float n11, float n12) {
296
+ float t0 = m00;
297
+ float t1 = m01;
298
+ m00 = n00 * t0 + n10 * t1;
299
+ m01 = n01 * t0 + n11 * t1;
300
+ m02 += n02 * t0 + n12 * t1;
301
+
302
+ t0 = m10;
303
+ t1 = m11;
304
+ m10 = n00 * t0 + n10 * t1;
305
+ m11 = n01 * t0 + n11 * t1;
306
+ m12 += n02 * t0 + n12 * t1;
307
+ }
308
+
309
+
310
+ /**
311
+ * Unavailable in 2D.
312
+ * @throws IllegalArgumentException
313
+ */
314
+ public void apply(float n00, float n01, float n02, float n03,
315
+ float n10, float n11, float n12, float n13,
316
+ float n20, float n21, float n22, float n23,
317
+ float n30, float n31, float n32, float n33) {
318
+ throw new IllegalArgumentException("Cannot use this version of apply() on a PMatrix2D.");
319
+ }
320
+
321
+
322
+ /**
323
+ * Apply another matrix to the left of this one.
324
+ */
325
+ @Override
326
+ public void preApply(PMatrix source) {
327
+ if (source instanceof PMatrix2D) {
328
+ preApply((PMatrix2D) source);
329
+ } else if (source instanceof PMatrix3D) {
330
+ preApply((PMatrix3D) source);
331
+ }
332
+ }
333
+
334
+
335
+ @Override
336
+ public void preApply(PMatrix2D left) {
337
+ preApply(left.m00, left.m01, left.m02,
338
+ left.m10, left.m11, left.m12);
339
+ }
340
+
341
+
342
+ /**
343
+ * Unavailable in 2D.
344
+ * @throws IllegalArgumentException
345
+ */
346
+ @Override
347
+ public void preApply(PMatrix3D left) {
348
+ throw new IllegalArgumentException("Cannot use preApply(PMatrix3D) on a PMatrix2D.");
349
+ }
350
+
351
+
352
+ @Override
353
+ public void preApply(float n00, float n01, float n02,
354
+ float n10, float n11, float n12) {
355
+ float t0 = m02;
356
+ float t1 = m12;
357
+ n02 += t0 * n00 + t1 * n01;
358
+ n12 += t0 * n10 + t1 * n11;
359
+
360
+ m02 = n02;
361
+ m12 = n12;
362
+
363
+ t0 = m00;
364
+ t1 = m10;
365
+ m00 = t0 * n00 + t1 * n01;
366
+ m10 = t0 * n10 + t1 * n11;
367
+
368
+ t0 = m01;
369
+ t1 = m11;
370
+ m01 = t0 * n00 + t1 * n01;
371
+ m11 = t0 * n10 + t1 * n11;
372
+ }
373
+
374
+
375
+ /**
376
+ * Unavailable in 2D.
377
+ * @throws IllegalArgumentException
378
+ */
379
+ public void preApply(float n00, float n01, float n02, float n03,
380
+ float n10, float n11, float n12, float n13,
381
+ float n20, float n21, float n22, float n23,
382
+ float n30, float n31, float n32, float n33) {
383
+ throw new IllegalArgumentException("Cannot use this version of preApply() on a PMatrix2D.");
384
+ }
385
+
386
+
387
+ //////////////////////////////////////////////////////////////
388
+
389
+
390
+ /**
391
+ * {@inheritDoc}
392
+ * Ignores any z component.
393
+ */
394
+ public PVector mult(PVector source, PVector target) {
395
+ if (target == null) {
396
+ target = new PVector();
397
+ }
398
+ target.x = m00*source.x + m01*source.y + m02;
399
+ target.y = m10*source.x + m11*source.y + m12;
400
+ return target;
401
+ }
402
+
403
+
404
+ /**
405
+ * Multiply a two element vector against this matrix.
406
+ * If out is null or not length four, a new float array will be returned.
407
+ * The values for vec and out can be the same (though that's less efficient).
408
+ */
409
+ public float[] mult(float[] vec, float[] out) {
410
+ if (out == null || out.length != 2) {
411
+ out = new float[2];
412
+ }
413
+
414
+ if (vec == out) {
415
+ float tx = m00*vec[0] + m01*vec[1] + m02;
416
+ float ty = m10*vec[0] + m11*vec[1] + m12;
417
+
418
+ out[0] = tx;
419
+ out[1] = ty;
420
+
421
+ } else {
422
+ out[0] = m00*vec[0] + m01*vec[1] + m02;
423
+ out[1] = m10*vec[0] + m11*vec[1] + m12;
424
+ }
425
+
426
+ return out;
427
+ }
428
+
429
+
430
+ /**
431
+ * Returns the x-coordinate of the result of multiplying the point (x, y)
432
+ * by this matrix.
433
+ */
434
+ public float multX(float x, float y) {
435
+ return m00*x + m01*y + m02;
436
+ }
437
+
438
+
439
+ /**
440
+ * Returns the y-coordinate of the result of multiplying the point (x, y)
441
+ * by this matrix.
442
+ */
443
+ public float multY(float x, float y) {
444
+ return m10*x + m11*y + m12;
445
+ }
446
+
447
+
448
+
449
+ /**
450
+ * Unavailable in 2D. Does nothing.
451
+ */
452
+ @Override
453
+ public void transpose() {
454
+ }
455
+
456
+
457
+ /*
458
+ * Implementation stolen from OpenJDK.
459
+ */
460
+ @Override
461
+ public boolean invert() {
462
+ float determinant = determinant();
463
+ if (Math.abs(determinant) <= Float.MIN_VALUE) {
464
+ return false;
465
+ }
466
+
467
+ float t00 = m00;
468
+ float t01 = m01;
469
+ float t02 = m02;
470
+ float t10 = m10;
471
+ float t11 = m11;
472
+ float t12 = m12;
473
+
474
+ m00 = t11 / determinant;
475
+ m10 = -t10 / determinant;
476
+ m01 = -t01 / determinant;
477
+ m11 = t00 / determinant;
478
+ m02 = (t01 * t12 - t11 * t02) / determinant;
479
+ m12 = (t10 * t02 - t00 * t12) / determinant;
480
+
481
+ return true;
482
+ }
483
+
484
+
485
+ /**
486
+ * @return the determinant of the matrix
487
+ */
488
+ @Override
489
+ public float determinant() {
490
+ return m00 * m11 - m01 * m10;
491
+ }
492
+
493
+
494
+ //////////////////////////////////////////////////////////////
495
+
496
+
497
+ public void print() {
498
+ int big = (int) abs(max(PApplet.max(abs(m00), abs(m01), abs(m02)),
499
+ PApplet.max(abs(m10), abs(m11), abs(m12))));
500
+
501
+ int digits = 1;
502
+ if (Float.isNaN(big) || Float.isInfinite(big)) { // avoid infinite loop
503
+ digits = 5;
504
+ } else {
505
+ while ((big /= 10) != 0) digits++; // cheap log()
506
+ }
507
+
508
+ System.out.println(PApplet.nfs(m00, digits, 4) + " " +
509
+ PApplet.nfs(m01, digits, 4) + " " +
510
+ PApplet.nfs(m02, digits, 4));
511
+
512
+ System.out.println(PApplet.nfs(m10, digits, 4) + " " +
513
+ PApplet.nfs(m11, digits, 4) + " " +
514
+ PApplet.nfs(m12, digits, 4));
515
+
516
+ System.out.println();
517
+ }
518
+
519
+
520
+ //////////////////////////////////////////////////////////////
521
+
522
+ // TODO these need to be added as regular API, but the naming and
523
+ // implementation needs to be improved first. (e.g. actually keeping track
524
+ // of whether the matrix is in fact identity internally.)
525
+
526
+
527
+ protected boolean isIdentity() {
528
+ return ((m00 == 1) && (m01 == 0) && (m02 == 0) &&
529
+ (m10 == 0) && (m11 == 1) && (m12 == 0));
530
+ }
531
+
532
+
533
+ // TODO make this more efficient, or move into PMatrix2D
534
+ protected boolean isWarped() {
535
+ return ((m00 != 1) || (m01 != 0) &&
536
+ (m10 != 0) || (m11 != 1));
537
+ }
538
+
539
+
540
+ //////////////////////////////////////////////////////////////
541
+
542
+
543
+ private static float max(float a, float b) {
544
+ return (a > b) ? a : b;
545
+ }
546
+
547
+ private static float abs(float a) {
548
+ return (a < 0) ? -a : a;
549
+ }
550
+
551
+ private static float sin(float angle) {
552
+ return (float)Math.sin(angle);
553
+ }
554
+
555
+ private static float cos(float angle) {
556
+ return (float)Math.cos(angle);
557
+ }
558
+
559
+ private static float tan(float angle) {
560
+ return (float)Math.tan(angle);
561
+ }
562
+ }