propane 3.10.0-java → 3.11.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/wrapper/maven-wrapper.properties +1 -1
- data/CHANGELOG.md +2 -0
- data/README.md +7 -7
- data/lib/propane/app.rb +2 -5
- data/lib/propane/helper_methods.rb +6 -6
- data/lib/propane/version.rb +1 -1
- data/lib/{propane-3.10.0.jar → propane-3.11.0.jar} +0 -0
- data/pom.rb +6 -6
- data/pom.xml +6 -6
- data/propane.gemspec +3 -3
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -13
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +14 -28
- data/src/main/java/processing/awt/PImageAWT.java +6 -4
- data/src/main/java/processing/core/PApplet.java +71 -59
- data/src/main/java/processing/core/PImage.java +14 -14
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
- data/src/main/java/processing/opengl/PShader.java +1 -6
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
- data/{lib/java/processing/opengl → src/main/resources}/cursors/arrow.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/cross.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/hand.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/license.txt +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/move.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/text.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/cursors/wait.png +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LightFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LightVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LineFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/LineVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/MaskFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/PointFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/PointVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightFrag.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightVert.glsl +0 -0
- data/{lib/java/processing/opengl → src/main/resources}/shaders/TexVert.glsl +0 -0
- data/test/test_helper.rb +1 -0
- data/vendors/Rakefile +1 -1
- metadata +29 -155
- data/lib/java/japplemenubar/JAppleMenuBar.java +0 -88
- data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
- data/lib/java/monkstone/ColorUtil.java +0 -127
- data/lib/java/monkstone/MathToolModule.java +0 -287
- data/lib/java/monkstone/PropaneLibrary.java +0 -46
- data/lib/java/monkstone/core/LibraryProxy.java +0 -136
- data/lib/java/monkstone/fastmath/DegLutTables.java +0 -111
- data/lib/java/monkstone/fastmath/Deglut.java +0 -71
- data/lib/java/monkstone/fastmath/package-info.java +0 -6
- data/lib/java/monkstone/filechooser/Chooser.java +0 -39
- data/lib/java/monkstone/noise/FastTerrain.java +0 -874
- data/lib/java/monkstone/noise/Noise.java +0 -90
- data/lib/java/monkstone/noise/NoiseGenerator.java +0 -75
- data/lib/java/monkstone/noise/NoiseMode.java +0 -28
- data/lib/java/monkstone/noise/OpenSimplex2F.java +0 -881
- data/lib/java/monkstone/noise/OpenSimplex2S.java +0 -1106
- data/lib/java/monkstone/noise/SmoothTerrain.java +0 -1099
- data/lib/java/monkstone/slider/CustomHorizontalSlider.java +0 -164
- data/lib/java/monkstone/slider/CustomVerticalSlider.java +0 -178
- data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +0 -145
- data/lib/java/monkstone/slider/SimpleSlider.java +0 -166
- data/lib/java/monkstone/slider/SimpleVerticalSlider.java +0 -157
- data/lib/java/monkstone/slider/Slider.java +0 -61
- data/lib/java/monkstone/slider/SliderBar.java +0 -245
- data/lib/java/monkstone/slider/SliderGroup.java +0 -56
- data/lib/java/monkstone/slider/WheelHandler.java +0 -35
- data/lib/java/monkstone/vecmath/GfxRender.java +0 -86
- data/lib/java/monkstone/vecmath/JRender.java +0 -56
- data/lib/java/monkstone/vecmath/ShapeRender.java +0 -87
- data/lib/java/monkstone/vecmath/package-info.java +0 -20
- data/lib/java/monkstone/vecmath/vec2/Vec2.java +0 -802
- data/lib/java/monkstone/vecmath/vec2/package-info.java +0 -6
- data/lib/java/monkstone/vecmath/vec3/Vec3.java +0 -727
- data/lib/java/monkstone/vecmath/vec3/package-info.java +0 -6
- data/lib/java/monkstone/videoevent/CaptureEvent.java +0 -27
- data/lib/java/monkstone/videoevent/MovieEvent.java +0 -32
- data/lib/java/monkstone/videoevent/package-info.java +0 -20
- data/lib/java/processing/awt/PGraphicsJava2D.java +0 -3040
- data/lib/java/processing/awt/PImageAWT.java +0 -377
- data/lib/java/processing/awt/PShapeJava2D.java +0 -387
- data/lib/java/processing/awt/PSurfaceAWT.java +0 -1581
- data/lib/java/processing/awt/ShimAWT.java +0 -581
- data/lib/java/processing/core/PApplet.java +0 -15156
- data/lib/java/processing/core/PConstants.java +0 -523
- data/lib/java/processing/core/PFont.java +0 -1126
- data/lib/java/processing/core/PGraphics.java +0 -8600
- data/lib/java/processing/core/PImage.java +0 -3377
- data/lib/java/processing/core/PMatrix.java +0 -208
- data/lib/java/processing/core/PMatrix2D.java +0 -562
- data/lib/java/processing/core/PMatrix3D.java +0 -890
- data/lib/java/processing/core/PShape.java +0 -3561
- data/lib/java/processing/core/PShapeOBJ.java +0 -483
- data/lib/java/processing/core/PShapeSVG.java +0 -2016
- data/lib/java/processing/core/PStyle.java +0 -63
- data/lib/java/processing/core/PSurface.java +0 -198
- data/lib/java/processing/core/PSurfaceNone.java +0 -431
- data/lib/java/processing/core/PVector.java +0 -1066
- data/lib/java/processing/core/ThinkDifferent.java +0 -115
- data/lib/java/processing/data/DoubleDict.java +0 -850
- data/lib/java/processing/data/DoubleList.java +0 -928
- data/lib/java/processing/data/FloatDict.java +0 -847
- data/lib/java/processing/data/FloatList.java +0 -936
- data/lib/java/processing/data/IntDict.java +0 -807
- data/lib/java/processing/data/IntList.java +0 -936
- data/lib/java/processing/data/JSONArray.java +0 -1260
- data/lib/java/processing/data/JSONObject.java +0 -2282
- data/lib/java/processing/data/JSONTokener.java +0 -435
- data/lib/java/processing/data/LongDict.java +0 -802
- data/lib/java/processing/data/LongList.java +0 -937
- data/lib/java/processing/data/Sort.java +0 -46
- data/lib/java/processing/data/StringDict.java +0 -613
- data/lib/java/processing/data/StringList.java +0 -800
- data/lib/java/processing/data/Table.java +0 -4936
- data/lib/java/processing/data/TableRow.java +0 -198
- data/lib/java/processing/data/XML.java +0 -1156
- data/lib/java/processing/dxf/RawDXF.java +0 -404
- data/lib/java/processing/event/Event.java +0 -125
- data/lib/java/processing/event/KeyEvent.java +0 -70
- data/lib/java/processing/event/MouseEvent.java +0 -114
- data/lib/java/processing/event/TouchEvent.java +0 -57
- data/lib/java/processing/javafx/PGraphicsFX2D.java +0 -32
- data/lib/java/processing/javafx/PSurfaceFX.java +0 -173
- data/lib/java/processing/net/Client.java +0 -744
- data/lib/java/processing/net/Server.java +0 -388
- data/lib/java/processing/opengl/FontTexture.java +0 -378
- data/lib/java/processing/opengl/FrameBuffer.java +0 -513
- data/lib/java/processing/opengl/LinePath.java +0 -627
- data/lib/java/processing/opengl/LineStroker.java +0 -681
- data/lib/java/processing/opengl/PGL.java +0 -3483
- data/lib/java/processing/opengl/PGraphics2D.java +0 -615
- data/lib/java/processing/opengl/PGraphics3D.java +0 -281
- data/lib/java/processing/opengl/PGraphicsOpenGL.java +0 -13753
- data/lib/java/processing/opengl/PJOGL.java +0 -2008
- data/lib/java/processing/opengl/PShader.java +0 -1484
- data/lib/java/processing/opengl/PShapeOpenGL.java +0 -5269
- data/lib/java/processing/opengl/PSurfaceJOGL.java +0 -1385
- data/lib/java/processing/opengl/Texture.java +0 -1696
- data/lib/java/processing/opengl/VertexBuffer.java +0 -88
- data/lib/java/processing/pdf/PGraphicsPDF.java +0 -581
- data/lib/java/processing/svg/PGraphicsSVG.java +0 -378
- data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
- data/src/main/java/processing/opengl/cursors/cross.png +0 -0
- data/src/main/java/processing/opengl/cursors/hand.png +0 -0
- data/src/main/java/processing/opengl/cursors/license.txt +0 -27
- data/src/main/java/processing/opengl/cursors/move.png +0 -0
- data/src/main/java/processing/opengl/cursors/text.png +0 -0
- data/src/main/java/processing/opengl/cursors/wait.png +0 -0
- data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +0 -32
- data/src/main/java/processing/opengl/shaders/ColorVert.glsl +0 -34
- data/src/main/java/processing/opengl/shaders/LightFrag.glsl +0 -33
- data/src/main/java/processing/opengl/shaders/LightVert.glsl +0 -151
- data/src/main/java/processing/opengl/shaders/LineFrag.glsl +0 -32
- data/src/main/java/processing/opengl/shaders/LineVert.glsl +0 -100
- data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +0 -40
- data/src/main/java/processing/opengl/shaders/PointFrag.glsl +0 -32
- data/src/main/java/processing/opengl/shaders/PointVert.glsl +0 -56
- data/src/main/java/processing/opengl/shaders/TexFrag.glsl +0 -37
- data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +0 -37
- data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +0 -157
- data/src/main/java/processing/opengl/shaders/TexVert.glsl +0 -38
@@ -1,562 +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-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
|
-
}
|