propane 3.10.0-java → 3.11.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 (163) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  3. data/CHANGELOG.md +2 -0
  4. data/README.md +7 -7
  5. data/lib/propane/app.rb +2 -5
  6. data/lib/propane/helper_methods.rb +6 -6
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{propane-3.10.0.jar → propane-3.11.0.jar} +0 -0
  9. data/pom.rb +6 -6
  10. data/pom.xml +6 -6
  11. data/propane.gemspec +3 -3
  12. data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
  13. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -13
  14. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +14 -28
  15. data/src/main/java/processing/awt/PImageAWT.java +6 -4
  16. data/src/main/java/processing/core/PApplet.java +71 -59
  17. data/src/main/java/processing/core/PImage.java +14 -14
  18. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
  19. data/src/main/java/processing/opengl/PShader.java +1 -6
  20. data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
  21. data/{lib/java/processing/opengl → src/main/resources}/cursors/arrow.png +0 -0
  22. data/{lib/java/processing/opengl → src/main/resources}/cursors/cross.png +0 -0
  23. data/{lib/java/processing/opengl → src/main/resources}/cursors/hand.png +0 -0
  24. data/{lib/java/processing/opengl → src/main/resources}/cursors/license.txt +0 -0
  25. data/{lib/java/processing/opengl → src/main/resources}/cursors/move.png +0 -0
  26. data/{lib/java/processing/opengl → src/main/resources}/cursors/text.png +0 -0
  27. data/{lib/java/processing/opengl → src/main/resources}/cursors/wait.png +0 -0
  28. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorFrag.glsl +0 -0
  29. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorVert.glsl +0 -0
  30. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightFrag.glsl +0 -0
  31. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightVert.glsl +0 -0
  32. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineFrag.glsl +0 -0
  33. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineVert.glsl +0 -0
  34. data/{lib/java/processing/opengl → src/main/resources}/shaders/MaskFrag.glsl +0 -0
  35. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointFrag.glsl +0 -0
  36. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointVert.glsl +0 -0
  37. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexFrag.glsl +0 -0
  38. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightFrag.glsl +0 -0
  39. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightVert.glsl +0 -0
  40. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexVert.glsl +0 -0
  41. data/test/test_helper.rb +1 -0
  42. data/vendors/Rakefile +1 -1
  43. metadata +29 -155
  44. data/lib/java/japplemenubar/JAppleMenuBar.java +0 -88
  45. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  46. data/lib/java/monkstone/ColorUtil.java +0 -127
  47. data/lib/java/monkstone/MathToolModule.java +0 -287
  48. data/lib/java/monkstone/PropaneLibrary.java +0 -46
  49. data/lib/java/monkstone/core/LibraryProxy.java +0 -136
  50. data/lib/java/monkstone/fastmath/DegLutTables.java +0 -111
  51. data/lib/java/monkstone/fastmath/Deglut.java +0 -71
  52. data/lib/java/monkstone/fastmath/package-info.java +0 -6
  53. data/lib/java/monkstone/filechooser/Chooser.java +0 -39
  54. data/lib/java/monkstone/noise/FastTerrain.java +0 -874
  55. data/lib/java/monkstone/noise/Noise.java +0 -90
  56. data/lib/java/monkstone/noise/NoiseGenerator.java +0 -75
  57. data/lib/java/monkstone/noise/NoiseMode.java +0 -28
  58. data/lib/java/monkstone/noise/OpenSimplex2F.java +0 -881
  59. data/lib/java/monkstone/noise/OpenSimplex2S.java +0 -1106
  60. data/lib/java/monkstone/noise/SmoothTerrain.java +0 -1099
  61. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +0 -164
  62. data/lib/java/monkstone/slider/CustomVerticalSlider.java +0 -178
  63. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +0 -145
  64. data/lib/java/monkstone/slider/SimpleSlider.java +0 -166
  65. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +0 -157
  66. data/lib/java/monkstone/slider/Slider.java +0 -61
  67. data/lib/java/monkstone/slider/SliderBar.java +0 -245
  68. data/lib/java/monkstone/slider/SliderGroup.java +0 -56
  69. data/lib/java/monkstone/slider/WheelHandler.java +0 -35
  70. data/lib/java/monkstone/vecmath/GfxRender.java +0 -86
  71. data/lib/java/monkstone/vecmath/JRender.java +0 -56
  72. data/lib/java/monkstone/vecmath/ShapeRender.java +0 -87
  73. data/lib/java/monkstone/vecmath/package-info.java +0 -20
  74. data/lib/java/monkstone/vecmath/vec2/Vec2.java +0 -802
  75. data/lib/java/monkstone/vecmath/vec2/package-info.java +0 -6
  76. data/lib/java/monkstone/vecmath/vec3/Vec3.java +0 -727
  77. data/lib/java/monkstone/vecmath/vec3/package-info.java +0 -6
  78. data/lib/java/monkstone/videoevent/CaptureEvent.java +0 -27
  79. data/lib/java/monkstone/videoevent/MovieEvent.java +0 -32
  80. data/lib/java/monkstone/videoevent/package-info.java +0 -20
  81. data/lib/java/processing/awt/PGraphicsJava2D.java +0 -3040
  82. data/lib/java/processing/awt/PImageAWT.java +0 -377
  83. data/lib/java/processing/awt/PShapeJava2D.java +0 -387
  84. data/lib/java/processing/awt/PSurfaceAWT.java +0 -1581
  85. data/lib/java/processing/awt/ShimAWT.java +0 -581
  86. data/lib/java/processing/core/PApplet.java +0 -15156
  87. data/lib/java/processing/core/PConstants.java +0 -523
  88. data/lib/java/processing/core/PFont.java +0 -1126
  89. data/lib/java/processing/core/PGraphics.java +0 -8600
  90. data/lib/java/processing/core/PImage.java +0 -3377
  91. data/lib/java/processing/core/PMatrix.java +0 -208
  92. data/lib/java/processing/core/PMatrix2D.java +0 -562
  93. data/lib/java/processing/core/PMatrix3D.java +0 -890
  94. data/lib/java/processing/core/PShape.java +0 -3561
  95. data/lib/java/processing/core/PShapeOBJ.java +0 -483
  96. data/lib/java/processing/core/PShapeSVG.java +0 -2016
  97. data/lib/java/processing/core/PStyle.java +0 -63
  98. data/lib/java/processing/core/PSurface.java +0 -198
  99. data/lib/java/processing/core/PSurfaceNone.java +0 -431
  100. data/lib/java/processing/core/PVector.java +0 -1066
  101. data/lib/java/processing/core/ThinkDifferent.java +0 -115
  102. data/lib/java/processing/data/DoubleDict.java +0 -850
  103. data/lib/java/processing/data/DoubleList.java +0 -928
  104. data/lib/java/processing/data/FloatDict.java +0 -847
  105. data/lib/java/processing/data/FloatList.java +0 -936
  106. data/lib/java/processing/data/IntDict.java +0 -807
  107. data/lib/java/processing/data/IntList.java +0 -936
  108. data/lib/java/processing/data/JSONArray.java +0 -1260
  109. data/lib/java/processing/data/JSONObject.java +0 -2282
  110. data/lib/java/processing/data/JSONTokener.java +0 -435
  111. data/lib/java/processing/data/LongDict.java +0 -802
  112. data/lib/java/processing/data/LongList.java +0 -937
  113. data/lib/java/processing/data/Sort.java +0 -46
  114. data/lib/java/processing/data/StringDict.java +0 -613
  115. data/lib/java/processing/data/StringList.java +0 -800
  116. data/lib/java/processing/data/Table.java +0 -4936
  117. data/lib/java/processing/data/TableRow.java +0 -198
  118. data/lib/java/processing/data/XML.java +0 -1156
  119. data/lib/java/processing/dxf/RawDXF.java +0 -404
  120. data/lib/java/processing/event/Event.java +0 -125
  121. data/lib/java/processing/event/KeyEvent.java +0 -70
  122. data/lib/java/processing/event/MouseEvent.java +0 -114
  123. data/lib/java/processing/event/TouchEvent.java +0 -57
  124. data/lib/java/processing/javafx/PGraphicsFX2D.java +0 -32
  125. data/lib/java/processing/javafx/PSurfaceFX.java +0 -173
  126. data/lib/java/processing/net/Client.java +0 -744
  127. data/lib/java/processing/net/Server.java +0 -388
  128. data/lib/java/processing/opengl/FontTexture.java +0 -378
  129. data/lib/java/processing/opengl/FrameBuffer.java +0 -513
  130. data/lib/java/processing/opengl/LinePath.java +0 -627
  131. data/lib/java/processing/opengl/LineStroker.java +0 -681
  132. data/lib/java/processing/opengl/PGL.java +0 -3483
  133. data/lib/java/processing/opengl/PGraphics2D.java +0 -615
  134. data/lib/java/processing/opengl/PGraphics3D.java +0 -281
  135. data/lib/java/processing/opengl/PGraphicsOpenGL.java +0 -13753
  136. data/lib/java/processing/opengl/PJOGL.java +0 -2008
  137. data/lib/java/processing/opengl/PShader.java +0 -1484
  138. data/lib/java/processing/opengl/PShapeOpenGL.java +0 -5269
  139. data/lib/java/processing/opengl/PSurfaceJOGL.java +0 -1385
  140. data/lib/java/processing/opengl/Texture.java +0 -1696
  141. data/lib/java/processing/opengl/VertexBuffer.java +0 -88
  142. data/lib/java/processing/pdf/PGraphicsPDF.java +0 -581
  143. data/lib/java/processing/svg/PGraphicsSVG.java +0 -378
  144. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  145. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  146. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  147. data/src/main/java/processing/opengl/cursors/license.txt +0 -27
  148. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  149. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  150. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  151. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +0 -32
  152. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +0 -34
  153. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +0 -33
  154. data/src/main/java/processing/opengl/shaders/LightVert.glsl +0 -151
  155. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +0 -32
  156. data/src/main/java/processing/opengl/shaders/LineVert.glsl +0 -100
  157. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +0 -40
  158. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +0 -32
  159. data/src/main/java/processing/opengl/shaders/PointVert.glsl +0 -56
  160. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +0 -37
  161. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +0 -37
  162. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +0 -157
  163. data/src/main/java/processing/opengl/shaders/TexVert.glsl +0 -38
@@ -1,890 +0,0 @@
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-12 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 version 2.1 as published by the Free Software Foundation.
11
-
12
- This library is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- Lesser General Public License for more details.
16
-
17
- You should have received a copy of the GNU Lesser General
18
- Public License along with this library; if not, write to the
19
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
- Boston, MA 02111-1307 USA
21
- */
22
-
23
- package processing.core;
24
-
25
-
26
- /**
27
- * 4x4 matrix implementation.
28
- * Matrices are used to describe a transformation; see {@link PMatrix} for a
29
- * general description. This matrix looks like the following when multiplying
30
- * a vector (x, y, z, w) in {@code mult()}.
31
- * <pre>
32
- * [m00 m01 m02 m03][x] [m00*x + m01*y + m02*z + m03*w] [x']
33
- * [m10 m11 m12 m13][y] = [m10*x + m11*y + m12*z + m13*w] = [y']
34
- * [m20 m21 m22 m23][z] [m20*x + m21*y + m22*z + m23*w] [z']
35
- * [m30 m31 m32 m33][w] [m30*x + m31*y + m32*z + m33*w] [w']</pre>
36
- * (x', y', z', w') is returned. The values in the matrix determine the
37
- * transformation. They are modified by the various transformation functions.
38
- *
39
- * To transform 3D coordinates, w is set to 1, amd w' is made to be 1 by
40
- * setting the bottom row of the matrix to <code>[0 0 0 1]</code>. The
41
- * resulting point is then (x', y', z').
42
- */
43
- public final class PMatrix3D implements PMatrix /*, PConstants*/ {
44
-
45
- public float m00, m01, m02, m03;
46
- public float m10, m11, m12, m13;
47
- public float m20, m21, m22, m23;
48
- public float m30, m31, m32, m33;
49
-
50
-
51
- // locally allocated version to avoid creating new memory
52
- protected PMatrix3D inverseCopy;
53
-
54
-
55
- public PMatrix3D() {
56
- reset();
57
- }
58
-
59
-
60
- public PMatrix3D(float m00, float m01, float m02,
61
- float m10, float m11, float m12) {
62
- set(m00, m01, m02, 0,
63
- m10, m11, m12, 0,
64
- 0, 0, 1, 0,
65
- 0, 0, 0, 1);
66
- }
67
-
68
-
69
- public PMatrix3D(float m00, float m01, float m02, float m03,
70
- float m10, float m11, float m12, float m13,
71
- float m20, float m21, float m22, float m23,
72
- float m30, float m31, float m32, float m33) {
73
- set(m00, m01, m02, m03,
74
- m10, m11, m12, m13,
75
- m20, m21, m22, m23,
76
- m30, m31, m32, m33);
77
- }
78
-
79
-
80
- public PMatrix3D(PMatrix matrix) {
81
- set(matrix);
82
- }
83
-
84
-
85
- public void reset() {
86
- set(1, 0, 0, 0,
87
- 0, 1, 0, 0,
88
- 0, 0, 1, 0,
89
- 0, 0, 0, 1);
90
- }
91
-
92
-
93
- /**
94
- * Returns a copy of this PMatrix.
95
- */
96
- public PMatrix3D get() {
97
- PMatrix3D outgoing = new PMatrix3D();
98
- outgoing.set(this);
99
- return outgoing;
100
- }
101
-
102
-
103
- /**
104
- * Copies the matrix contents into a 16 entry float array.
105
- * If target is null (or not the correct size), a new array will be created.
106
- */
107
- public float[] get(float[] target) {
108
- if ((target == null) || (target.length != 16)) {
109
- target = new float[16];
110
- }
111
- target[0] = m00;
112
- target[1] = m01;
113
- target[2] = m02;
114
- target[3] = m03;
115
-
116
- target[4] = m10;
117
- target[5] = m11;
118
- target[6] = m12;
119
- target[7] = m13;
120
-
121
- target[8] = m20;
122
- target[9] = m21;
123
- target[10] = m22;
124
- target[11] = m23;
125
-
126
- target[12] = m30;
127
- target[13] = m31;
128
- target[14] = m32;
129
- target[15] = m33;
130
-
131
- return target;
132
- }
133
-
134
-
135
- public void set(PMatrix matrix) {
136
- if (matrix instanceof PMatrix3D) {
137
- PMatrix3D src = (PMatrix3D) matrix;
138
- set(src.m00, src.m01, src.m02, src.m03,
139
- src.m10, src.m11, src.m12, src.m13,
140
- src.m20, src.m21, src.m22, src.m23,
141
- src.m30, src.m31, src.m32, src.m33);
142
- } else {
143
- PMatrix2D src = (PMatrix2D) matrix;
144
- set(src.m00, src.m01, 0, src.m02,
145
- src.m10, src.m11, 0, src.m12,
146
- 0, 0, 1, 0,
147
- 0, 0, 0, 1);
148
- }
149
- }
150
-
151
-
152
- @Override
153
- public void set(float[] source) {
154
- if (source.length == 6) {
155
- set(source[0], source[1], source[2],
156
- source[3], source[4], source[5]);
157
-
158
- } else if (source.length == 16) {
159
- m00 = source[0];
160
- m01 = source[1];
161
- m02 = source[2];
162
- m03 = source[3];
163
-
164
- m10 = source[4];
165
- m11 = source[5];
166
- m12 = source[6];
167
- m13 = source[7];
168
-
169
- m20 = source[8];
170
- m21 = source[9];
171
- m22 = source[10];
172
- m23 = source[11];
173
-
174
- m30 = source[12];
175
- m31 = source[13];
176
- m32 = source[14];
177
- m33 = source[15];
178
- }
179
- }
180
-
181
-
182
- @Override
183
- public void set(float m00, float m01, float m02,
184
- float m10, float m11, float m12) {
185
- set(m00, m01, 0, m02,
186
- m10, m11, 0, m12,
187
- 0, 0, 1, 0,
188
- 0, 0, 0, 1);
189
- }
190
-
191
-
192
- @Override
193
- public void set(float m00, float m01, float m02, float m03,
194
- float m10, float m11, float m12, float m13,
195
- float m20, float m21, float m22, float m23,
196
- float m30, float m31, float m32, float m33) {
197
- this.m00 = m00; this.m01 = m01; this.m02 = m02; this.m03 = m03;
198
- this.m10 = m10; this.m11 = m11; this.m12 = m12; this.m13 = m13;
199
- this.m20 = m20; this.m21 = m21; this.m22 = m22; this.m23 = m23;
200
- this.m30 = m30; this.m31 = m31; this.m32 = m32; this.m33 = m33;
201
- }
202
-
203
-
204
- @Override
205
- public void translate(float tx, float ty) {
206
- translate(tx, ty, 0);
207
- }
208
-
209
- // public void invTranslate(float tx, float ty) {
210
- // invTranslate(tx, ty, 0);
211
- // }
212
-
213
-
214
- @Override
215
- public void translate(float tx, float ty, float tz) {
216
- m03 += tx*m00 + ty*m01 + tz*m02;
217
- m13 += tx*m10 + ty*m11 + tz*m12;
218
- m23 += tx*m20 + ty*m21 + tz*m22;
219
- m33 += tx*m30 + ty*m31 + tz*m32;
220
- }
221
-
222
-
223
- @Override
224
- public void rotate(float angle) {
225
- rotateZ(angle);
226
- }
227
-
228
-
229
- @Override
230
- public void rotateX(float angle) {
231
- float c = cos(angle);
232
- float s = sin(angle);
233
- apply(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
234
- }
235
-
236
-
237
- @Override
238
- public void rotateY(float angle) {
239
- float c = cos(angle);
240
- float s = sin(angle);
241
- apply(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
242
- }
243
-
244
-
245
- @Override
246
- public void rotateZ(float angle) {
247
- float c = cos(angle);
248
- float s = sin(angle);
249
- apply(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
250
- }
251
-
252
-
253
- @Override
254
- public void rotate(float angle, float v0, float v1, float v2) {
255
- float norm2 = v0 * v0 + v1 * v1 + v2 * v2;
256
- if (norm2 < PConstants.EPSILON) {
257
- // The vector is zero, cannot apply rotation.
258
- return;
259
- }
260
-
261
- if (Math.abs(norm2 - 1) > PConstants.EPSILON) {
262
- // The rotation vector is not normalized.
263
- float norm = PApplet.sqrt(norm2);
264
- v0 /= norm;
265
- v1 /= norm;
266
- v2 /= norm;
267
- }
268
-
269
- float c = cos(angle);
270
- float s = sin(angle);
271
- float t = 1.0f - c;
272
-
273
- apply((t*v0*v0) + c, (t*v0*v1) - (s*v2), (t*v0*v2) + (s*v1), 0,
274
- (t*v0*v1) + (s*v2), (t*v1*v1) + c, (t*v1*v2) - (s*v0), 0,
275
- (t*v0*v2) - (s*v1), (t*v1*v2) + (s*v0), (t*v2*v2) + c, 0,
276
- 0, 0, 0, 1);
277
- }
278
-
279
-
280
- public void scale(float s) {
281
- //apply(s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1);
282
- scale(s, s, s);
283
- }
284
-
285
-
286
- public void scale(float sx, float sy) {
287
- //apply(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
288
- scale(sx, sy, 1);
289
- }
290
-
291
-
292
- public void scale(float x, float y, float z) {
293
- //apply(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
294
- m00 *= x; m01 *= y; m02 *= z;
295
- m10 *= x; m11 *= y; m12 *= z;
296
- m20 *= x; m21 *= y; m22 *= z;
297
- m30 *= x; m31 *= y; m32 *= z;
298
- }
299
-
300
-
301
- public void shearX(float angle) {
302
- float t = (float) Math.tan(angle);
303
- apply(1, t, 0, 0,
304
- 0, 1, 0, 0,
305
- 0, 0, 1, 0,
306
- 0, 0, 0, 1);
307
- }
308
-
309
-
310
- public void shearY(float angle) {
311
- float t = (float) Math.tan(angle);
312
- apply(1, 0, 0, 0,
313
- t, 1, 0, 0,
314
- 0, 0, 1, 0,
315
- 0, 0, 0, 1);
316
- }
317
-
318
-
319
- public void apply(PMatrix source) {
320
- if (source instanceof PMatrix2D) {
321
- apply((PMatrix2D) source);
322
- } else if (source instanceof PMatrix3D) {
323
- apply((PMatrix3D) source);
324
- }
325
- }
326
-
327
-
328
- public void apply(PMatrix2D source) {
329
- apply(source.m00, source.m01, 0, source.m02,
330
- source.m10, source.m11, 0, source.m12,
331
- 0, 0, 1, 0,
332
- 0, 0, 0, 1);
333
- }
334
-
335
-
336
- public void apply(PMatrix3D source) {
337
- apply(source.m00, source.m01, source.m02, source.m03,
338
- source.m10, source.m11, source.m12, source.m13,
339
- source.m20, source.m21, source.m22, source.m23,
340
- source.m30, source.m31, source.m32, source.m33);
341
- }
342
-
343
-
344
- public void apply(float n00, float n01, float n02,
345
- float n10, float n11, float n12) {
346
- apply(n00, n01, 0, n02,
347
- n10, n11, 0, n12,
348
- 0, 0, 1, 0,
349
- 0, 0, 0, 1);
350
- }
351
-
352
-
353
- public void apply(float n00, float n01, float n02, float n03,
354
- float n10, float n11, float n12, float n13,
355
- float n20, float n21, float n22, float n23,
356
- float n30, float n31, float n32, float n33) {
357
-
358
- float r00 = m00*n00 + m01*n10 + m02*n20 + m03*n30;
359
- float r01 = m00*n01 + m01*n11 + m02*n21 + m03*n31;
360
- float r02 = m00*n02 + m01*n12 + m02*n22 + m03*n32;
361
- float r03 = m00*n03 + m01*n13 + m02*n23 + m03*n33;
362
-
363
- float r10 = m10*n00 + m11*n10 + m12*n20 + m13*n30;
364
- float r11 = m10*n01 + m11*n11 + m12*n21 + m13*n31;
365
- float r12 = m10*n02 + m11*n12 + m12*n22 + m13*n32;
366
- float r13 = m10*n03 + m11*n13 + m12*n23 + m13*n33;
367
-
368
- float r20 = m20*n00 + m21*n10 + m22*n20 + m23*n30;
369
- float r21 = m20*n01 + m21*n11 + m22*n21 + m23*n31;
370
- float r22 = m20*n02 + m21*n12 + m22*n22 + m23*n32;
371
- float r23 = m20*n03 + m21*n13 + m22*n23 + m23*n33;
372
-
373
- float r30 = m30*n00 + m31*n10 + m32*n20 + m33*n30;
374
- float r31 = m30*n01 + m31*n11 + m32*n21 + m33*n31;
375
- float r32 = m30*n02 + m31*n12 + m32*n22 + m33*n32;
376
- float r33 = m30*n03 + m31*n13 + m32*n23 + m33*n33;
377
-
378
- m00 = r00; m01 = r01; m02 = r02; m03 = r03;
379
- m10 = r10; m11 = r11; m12 = r12; m13 = r13;
380
- m20 = r20; m21 = r21; m22 = r22; m23 = r23;
381
- m30 = r30; m31 = r31; m32 = r32; m33 = r33;
382
- }
383
-
384
-
385
- /**
386
- * Apply the 3D equivalent of the 2D matrix supplied to the left of this one.
387
- */
388
- public void preApply(PMatrix2D left) {
389
- preApply(left.m00, left.m01, 0, left.m02,
390
- left.m10, left.m11, 0, left.m12,
391
- 0, 0, 1, 0,
392
- 0, 0, 0, 1);
393
- }
394
-
395
-
396
- /**
397
- * Apply another matrix to the left of this one.
398
- */
399
- public void preApply(PMatrix source) {
400
- if (source instanceof PMatrix2D) {
401
- preApply((PMatrix2D) source);
402
- } else if (source instanceof PMatrix3D) {
403
- preApply((PMatrix3D) source);
404
- }
405
- }
406
-
407
-
408
- /**
409
- * Apply another matrix to the left of this one.
410
- */
411
- public void preApply(PMatrix3D left) {
412
- preApply(left.m00, left.m01, left.m02, left.m03,
413
- left.m10, left.m11, left.m12, left.m13,
414
- left.m20, left.m21, left.m22, left.m23,
415
- left.m30, left.m31, left.m32, left.m33);
416
- }
417
-
418
-
419
- /**
420
- * Apply the 3D equivalent of the 2D matrix supplied to the left of this one.
421
- */
422
- public void preApply(float n00, float n01, float n02,
423
- float n10, float n11, float n12) {
424
- preApply(n00, n01, 0, n02,
425
- n10, n11, 0, n12,
426
- 0, 0, 1, 0,
427
- 0, 0, 0, 1);
428
- }
429
-
430
-
431
- /**
432
- * Apply another matrix to the left of this one.
433
- */
434
- public void preApply(float n00, float n01, float n02, float n03,
435
- float n10, float n11, float n12, float n13,
436
- float n20, float n21, float n22, float n23,
437
- float n30, float n31, float n32, float n33) {
438
-
439
- float r00 = n00*m00 + n01*m10 + n02*m20 + n03*m30;
440
- float r01 = n00*m01 + n01*m11 + n02*m21 + n03*m31;
441
- float r02 = n00*m02 + n01*m12 + n02*m22 + n03*m32;
442
- float r03 = n00*m03 + n01*m13 + n02*m23 + n03*m33;
443
-
444
- float r10 = n10*m00 + n11*m10 + n12*m20 + n13*m30;
445
- float r11 = n10*m01 + n11*m11 + n12*m21 + n13*m31;
446
- float r12 = n10*m02 + n11*m12 + n12*m22 + n13*m32;
447
- float r13 = n10*m03 + n11*m13 + n12*m23 + n13*m33;
448
-
449
- float r20 = n20*m00 + n21*m10 + n22*m20 + n23*m30;
450
- float r21 = n20*m01 + n21*m11 + n22*m21 + n23*m31;
451
- float r22 = n20*m02 + n21*m12 + n22*m22 + n23*m32;
452
- float r23 = n20*m03 + n21*m13 + n22*m23 + n23*m33;
453
-
454
- float r30 = n30*m00 + n31*m10 + n32*m20 + n33*m30;
455
- float r31 = n30*m01 + n31*m11 + n32*m21 + n33*m31;
456
- float r32 = n30*m02 + n31*m12 + n32*m22 + n33*m32;
457
- float r33 = n30*m03 + n31*m13 + n32*m23 + n33*m33;
458
-
459
- m00 = r00; m01 = r01; m02 = r02; m03 = r03;
460
- m10 = r10; m11 = r11; m12 = r12; m13 = r13;
461
- m20 = r20; m21 = r21; m22 = r22; m23 = r23;
462
- m30 = r30; m31 = r31; m32 = r32; m33 = r33;
463
- }
464
-
465
-
466
- //////////////////////////////////////////////////////////////
467
-
468
-
469
- /**
470
- * Multiply source by this matrix, and return the result.
471
- * The result will be stored in target if target is non-null, and target
472
- * will then be the matrix returned. This improves performance if you reuse
473
- * target, so it's recommended if you call this many times in draw().
474
- */
475
- public PVector mult(PVector source, PVector target) {
476
- if (target == null) {
477
- target = new PVector();
478
- }
479
- target.set(m00*source.x + m01*source.y + m02*source.z + m03,
480
- m10*source.x + m11*source.y + m12*source.z + m13,
481
- m20*source.x + m21*source.y + m22*source.z + m23);
482
- // float tw = m30*source.x + m31*source.y + m32*source.z + m33;
483
- // if (tw != 0 && tw != 1) {
484
- // target.div(tw);
485
- // }
486
- return target;
487
- }
488
-
489
-
490
- /*
491
- public PVector cmult(PVector source, PVector target) {
492
- if (target == null) {
493
- target = new PVector();
494
- }
495
- target.x = m00*source.x + m10*source.y + m20*source.z + m30;
496
- target.y = m01*source.x + m11*source.y + m21*source.z + m31;
497
- target.z = m02*source.x + m12*source.y + m22*source.z + m32;
498
- float tw = m03*source.x + m13*source.y + m23*source.z + m33;
499
- if (tw != 0 && tw != 1) {
500
- target.div(tw);
501
- }
502
- return target;
503
- }
504
- */
505
-
506
-
507
- /**
508
- * Multiply a three or four element vector against this matrix. If out is
509
- * null or not length 3 or 4, a new float array (length 3) will be returned.
510
- * Supplying and recycling a target array improves performance, so it's
511
- * recommended if you call this many times in draw.
512
- */
513
- public float[] mult(float[] source, float[] target) {
514
- if (target == null || target.length < 3) {
515
- target = new float[3];
516
- }
517
- if (source == target) {
518
- throw new RuntimeException("The source and target vectors used in " +
519
- "PMatrix3D.mult() cannot be identical.");
520
- }
521
- if (target.length == 3) {
522
- target[0] = m00*source[0] + m01*source[1] + m02*source[2] + m03;
523
- target[1] = m10*source[0] + m11*source[1] + m12*source[2] + m13;
524
- target[2] = m20*source[0] + m21*source[1] + m22*source[2] + m23;
525
- //float w = m30*source[0] + m31*source[1] + m32*source[2] + m33;
526
- //if (w != 0 && w != 1) {
527
- // target[0] /= w; target[1] /= w; target[2] /= w;
528
- //}
529
- } else if (target.length > 3) {
530
- target[0] = m00*source[0] + m01*source[1] + m02*source[2] + m03*source[3];
531
- target[1] = m10*source[0] + m11*source[1] + m12*source[2] + m13*source[3];
532
- target[2] = m20*source[0] + m21*source[1] + m22*source[2] + m23*source[3];
533
- target[3] = m30*source[0] + m31*source[1] + m32*source[2] + m33*source[3];
534
- }
535
- return target;
536
- }
537
-
538
-
539
- /**
540
- * Returns the x-coordinate of the result of multiplying the point (x, y)
541
- * by this matrix.
542
- */
543
- public float multX(float x, float y) {
544
- return m00*x + m01*y + m03;
545
- }
546
-
547
-
548
- /**
549
- * Returns the y-coordinate of the result of multiplying the point (x, y)
550
- * by this matrix.
551
- */
552
- public float multY(float x, float y) {
553
- return m10*x + m11*y + m13;
554
- }
555
-
556
-
557
- /**
558
- * Returns the x-coordinate of the result of multiplying the point (x, y, z)
559
- * by this matrix.
560
- */
561
- public float multX(float x, float y, float z) {
562
- return m00*x + m01*y + m02*z + m03;
563
- }
564
-
565
-
566
- /**
567
- * Returns the y-coordinate of the result of multiplying the point (x, y, z)
568
- * by this matrix.
569
- */
570
- public float multY(float x, float y, float z) {
571
- return m10*x + m11*y + m12*z + m13;
572
- }
573
-
574
-
575
- /**
576
- * Returns the z-coordinate of the result of multiplying the point (x, y, z)
577
- * by this matrix.
578
- */
579
- public float multZ(float x, float y, float z) {
580
- return m20*x + m21*y + m22*z + m23;
581
- }
582
-
583
-
584
- /**
585
- * Returns the fourth element of the result of multiplying the vector
586
- * (x, y, z) by this matrix. (Acts as if w = 1 was supplied.)
587
- */
588
- public float multW(float x, float y, float z) {
589
- return m30*x + m31*y + m32*z + m33;
590
- }
591
-
592
-
593
- /**
594
- * Returns the x-coordinate of the result of multiplying the vector
595
- * (x, y, z, w) by this matrix.
596
- */
597
- public float multX(float x, float y, float z, float w) {
598
- return m00*x + m01*y + m02*z + m03*w;
599
- }
600
-
601
-
602
- /**
603
- * Returns the y-coordinate of the result of multiplying the vector
604
- * (x, y, z, w) by this matrix.
605
- */
606
- public float multY(float x, float y, float z, float w) {
607
- return m10*x + m11*y + m12*z + m13*w;
608
- }
609
-
610
-
611
- /**
612
- * Returns the z-coordinate of the result of multiplying the vector
613
- * (x, y, z, w) by this matrix.
614
- */
615
- public float multZ(float x, float y, float z, float w) {
616
- return m20*x + m21*y + m22*z + m23*w;
617
- }
618
-
619
-
620
- /**
621
- * Returns the w-coordinate of the result of multiplying the vector
622
- * (x, y, z, w) by this matrix.
623
- */
624
- public float multW(float x, float y, float z, float w) {
625
- return m30*x + m31*y + m32*z + m33*w;
626
- }
627
-
628
-
629
- /**
630
- * Transpose this matrix; rows become columns and columns rows.
631
- */
632
- @Override
633
- public void transpose() {
634
- float temp;
635
- temp = m01; m01 = m10; m10 = temp;
636
- temp = m02; m02 = m20; m20 = temp;
637
- temp = m03; m03 = m30; m30 = temp;
638
- temp = m12; m12 = m21; m21 = temp;
639
- temp = m13; m13 = m31; m31 = temp;
640
- temp = m23; m23 = m32; m32 = temp;
641
- }
642
-
643
-
644
- /**
645
- * Invert this matrix. Will not necessarily succeed, because some matrices
646
- * map more than one point to the same image point, and so are irreversible.
647
- * @return true if successful
648
- */
649
- @Override
650
- public boolean invert() {
651
- float determinant = determinant();
652
- if (determinant == 0) {
653
- return false;
654
- }
655
-
656
- // first row
657
- float t00 = determinant3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33);
658
- float t01 = -determinant3x3(m10, m12, m13, m20, m22, m23, m30, m32, m33);
659
- float t02 = determinant3x3(m10, m11, m13, m20, m21, m23, m30, m31, m33);
660
- float t03 = -determinant3x3(m10, m11, m12, m20, m21, m22, m30, m31, m32);
661
-
662
- // second row
663
- float t10 = -determinant3x3(m01, m02, m03, m21, m22, m23, m31, m32, m33);
664
- float t11 = determinant3x3(m00, m02, m03, m20, m22, m23, m30, m32, m33);
665
- float t12 = -determinant3x3(m00, m01, m03, m20, m21, m23, m30, m31, m33);
666
- float t13 = determinant3x3(m00, m01, m02, m20, m21, m22, m30, m31, m32);
667
-
668
- // third row
669
- float t20 = determinant3x3(m01, m02, m03, m11, m12, m13, m31, m32, m33);
670
- float t21 = -determinant3x3(m00, m02, m03, m10, m12, m13, m30, m32, m33);
671
- float t22 = determinant3x3(m00, m01, m03, m10, m11, m13, m30, m31, m33);
672
- float t23 = -determinant3x3(m00, m01, m02, m10, m11, m12, m30, m31, m32);
673
-
674
- // fourth row
675
- float t30 = -determinant3x3(m01, m02, m03, m11, m12, m13, m21, m22, m23);
676
- float t31 = determinant3x3(m00, m02, m03, m10, m12, m13, m20, m22, m23);
677
- float t32 = -determinant3x3(m00, m01, m03, m10, m11, m13, m20, m21, m23);
678
- float t33 = determinant3x3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
679
-
680
- // transpose and divide by the determinant
681
- m00 = t00 / determinant;
682
- m01 = t10 / determinant;
683
- m02 = t20 / determinant;
684
- m03 = t30 / determinant;
685
-
686
- m10 = t01 / determinant;
687
- m11 = t11 / determinant;
688
- m12 = t21 / determinant;
689
- m13 = t31 / determinant;
690
-
691
- m20 = t02 / determinant;
692
- m21 = t12 / determinant;
693
- m22 = t22 / determinant;
694
- m23 = t32 / determinant;
695
-
696
- m30 = t03 / determinant;
697
- m31 = t13 / determinant;
698
- m32 = t23 / determinant;
699
- m33 = t33 / determinant;
700
-
701
- return true;
702
- }
703
-
704
-
705
- /**
706
- * Calculate the determinant of a 3x3 matrix.
707
- * @return result
708
- */
709
- private float determinant3x3(float t00, float t01, float t02,
710
- float t10, float t11, float t12,
711
- float t20, float t21, float t22) {
712
- return (t00 * (t11 * t22 - t12 * t21) +
713
- t01 * (t12 * t20 - t10 * t22) +
714
- t02 * (t10 * t21 - t11 * t20));
715
- }
716
-
717
-
718
- /**
719
- * @return the determinant of the matrix
720
- */
721
- @Override
722
- public float determinant() {
723
- float f =
724
- m00
725
- * ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32)
726
- - m13 * m22 * m31
727
- - m11 * m23 * m32
728
- - m12 * m21 * m33);
729
- f -= m01
730
- * ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32)
731
- - m13 * m22 * m30
732
- - m10 * m23 * m32
733
- - m12 * m20 * m33);
734
- f += m02
735
- * ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31)
736
- - m13 * m21 * m30
737
- - m10 * m23 * m31
738
- - m11 * m20 * m33);
739
- f -= m03
740
- * ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31)
741
- - m12 * m21 * m30
742
- - m10 * m22 * m31
743
- - m11 * m20 * m32);
744
- return f;
745
- }
746
-
747
-
748
- //////////////////////////////////////////////////////////////
749
-
750
- // REVERSE VERSIONS OF MATRIX OPERATIONS
751
-
752
- // These functions should not be used, as they will be removed in the future.
753
-
754
-
755
- protected void invTranslate(float tx, float ty, float tz) {
756
- preApply(1, 0, 0, -tx,
757
- 0, 1, 0, -ty,
758
- 0, 0, 1, -tz,
759
- 0, 0, 0, 1);
760
- }
761
-
762
-
763
- protected void invRotateX(float angle) {
764
- float c = cos(-angle);
765
- float s = sin(-angle);
766
- preApply(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
767
- }
768
-
769
-
770
- protected void invRotateY(float angle) {
771
- float c = cos(-angle);
772
- float s = sin(-angle);
773
- preApply(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
774
- }
775
-
776
-
777
- protected void invRotateZ(float angle) {
778
- float c = cos(-angle);
779
- float s = sin(-angle);
780
- preApply(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
781
- }
782
-
783
-
784
- protected void invRotate(float angle, float v0, float v1, float v2) {
785
- //TODO should make sure this vector is normalized
786
-
787
- float c = cos(-angle);
788
- float s = sin(-angle);
789
- float t = 1.0f - c;
790
-
791
- preApply((t*v0*v0) + c, (t*v0*v1) - (s*v2), (t*v0*v2) + (s*v1), 0,
792
- (t*v0*v1) + (s*v2), (t*v1*v1) + c, (t*v1*v2) - (s*v0), 0,
793
- (t*v0*v2) - (s*v1), (t*v1*v2) + (s*v0), (t*v2*v2) + c, 0,
794
- 0, 0, 0, 1);
795
- }
796
-
797
-
798
- protected void invScale(float x, float y, float z) {
799
- preApply(1/x, 0, 0, 0, 0, 1/y, 0, 0, 0, 0, 1/z, 0, 0, 0, 0, 1);
800
- }
801
-
802
-
803
- protected boolean invApply(float n00, float n01, float n02, float n03,
804
- float n10, float n11, float n12, float n13,
805
- float n20, float n21, float n22, float n23,
806
- float n30, float n31, float n32, float n33) {
807
- if (inverseCopy == null) {
808
- inverseCopy = new PMatrix3D();
809
- }
810
- inverseCopy.set(n00, n01, n02, n03,
811
- n10, n11, n12, n13,
812
- n20, n21, n22, n23,
813
- n30, n31, n32, n33);
814
- if (!inverseCopy.invert()) {
815
- return false;
816
- }
817
- preApply(inverseCopy);
818
- return true;
819
- }
820
-
821
-
822
- //////////////////////////////////////////////////////////////
823
-
824
-
825
- public void print() {
826
- /*
827
- System.out.println(m00 + " " + m01 + " " + m02 + " " + m03 + "\n" +
828
- m10 + " " + m11 + " " + m12 + " " + m13 + "\n" +
829
- m20 + " " + m21 + " " + m22 + " " + m23 + "\n" +
830
- m30 + " " + m31 + " " + m32 + " " + m33 + "\n");
831
- */
832
- int big = (int) Math.abs(max(max(max(max(abs(m00), abs(m01)),
833
- max(abs(m02), abs(m03))),
834
- max(max(abs(m10), abs(m11)),
835
- max(abs(m12), abs(m13)))),
836
- max(max(max(abs(m20), abs(m21)),
837
- max(abs(m22), abs(m23))),
838
- max(max(abs(m30), abs(m31)),
839
- max(abs(m32), abs(m33))))));
840
-
841
- int digits = 1;
842
- if (Float.isNaN(big) || Float.isInfinite(big)) { // avoid infinite loop
843
- digits = 5;
844
- } else {
845
- while ((big /= 10) != 0) digits++; // cheap log()
846
- }
847
-
848
- System.out.println(PApplet.nfs(m00, digits, 4) + " " +
849
- PApplet.nfs(m01, digits, 4) + " " +
850
- PApplet.nfs(m02, digits, 4) + " " +
851
- PApplet.nfs(m03, digits, 4));
852
-
853
- System.out.println(PApplet.nfs(m10, digits, 4) + " " +
854
- PApplet.nfs(m11, digits, 4) + " " +
855
- PApplet.nfs(m12, digits, 4) + " " +
856
- PApplet.nfs(m13, digits, 4));
857
-
858
- System.out.println(PApplet.nfs(m20, digits, 4) + " " +
859
- PApplet.nfs(m21, digits, 4) + " " +
860
- PApplet.nfs(m22, digits, 4) + " " +
861
- PApplet.nfs(m23, digits, 4));
862
-
863
- System.out.println(PApplet.nfs(m30, digits, 4) + " " +
864
- PApplet.nfs(m31, digits, 4) + " " +
865
- PApplet.nfs(m32, digits, 4) + " " +
866
- PApplet.nfs(m33, digits, 4));
867
-
868
- System.out.println();
869
- }
870
-
871
-
872
- //////////////////////////////////////////////////////////////
873
-
874
-
875
- private static float max(float a, float b) {
876
- return (a > b) ? a : b;
877
- }
878
-
879
- private static float abs(float a) {
880
- return (a < 0) ? -a : a;
881
- }
882
-
883
- private static float sin(float angle) {
884
- return (float) Math.sin(angle);
885
- }
886
-
887
- private static float cos(float angle) {
888
- return (float) Math.cos(angle);
889
- }
890
- }