propane 2.7.2-java → 2.8.0.pre-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/CHANGELOG.md +1 -1
- data/README.md +10 -8
- data/Rakefile +1 -1
- data/lib/propane/app.rb +3 -3
- data/lib/propane/version.rb +1 -1
- data/lib/{processing-core.jar → propane-2.8.0.jar} +0 -0
- data/library/control_panel/control_panel.rb +3 -2
- data/pom.rb +89 -88
- data/pom.xml +75 -46
- data/propane.gemspec +1 -2
- data/src/main/java/japplemenubar/JAppleMenuBar.java +88 -0
- data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
- data/src/{monkstone → main/java/monkstone}/ColorUtil.java +0 -0
- data/src/{monkstone → main/java/monkstone}/MathToolModule.java +0 -0
- data/src/{monkstone → main/java/monkstone}/PropaneLibrary.java +0 -0
- data/src/{monkstone → main/java/monkstone}/core/LibraryProxy.java +0 -0
- data/src/{monkstone → main/java/monkstone}/fastmath/Deglut.java +0 -0
- data/src/{monkstone → main/java/monkstone}/fastmath/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/filechooser/Chooser.java +0 -0
- data/src/{monkstone → main/java/monkstone}/noise/SimplexNoise.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/CustomHorizontalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/CustomVerticalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleHorizontalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SimpleVerticalSlider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/Slider.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SliderBar.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/SliderGroup.java +0 -0
- data/src/{monkstone → main/java/monkstone}/slider/WheelHandler.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/AppRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/JRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/ShapeRender.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec2/Vec2.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec2/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec3/Vec3.java +0 -0
- data/src/{monkstone → main/java/monkstone}/vecmath/vec3/package-info.java +0 -0
- data/src/{monkstone → main/java/monkstone}/videoevent/VideoInterface.java +0 -0
- data/src/{monkstone → main/java/monkstone}/videoevent/package-info.java +0 -0
- data/src/main/java/processing/awt/PGraphicsJava2D.java +3029 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +377 -0
- data/src/main/java/processing/awt/PSurfaceAWT.java +1567 -0
- data/src/main/java/processing/core/PApplet.java +15709 -0
- data/src/main/java/processing/core/PConstants.java +527 -0
- data/src/main/java/processing/core/PFont.java +1098 -0
- data/src/main/java/processing/core/PGraphics.java +8467 -0
- data/src/main/java/processing/core/PImage.java +3438 -0
- data/src/main/java/processing/core/PMatrix.java +208 -0
- data/src/main/java/processing/core/PMatrix2D.java +534 -0
- data/src/main/java/processing/core/PMatrix3D.java +877 -0
- data/src/main/java/processing/core/PShape.java +3445 -0
- data/src/main/java/processing/core/PShapeOBJ.java +469 -0
- data/src/main/java/processing/core/PShapeSVG.java +1787 -0
- data/src/main/java/processing/core/PStyle.java +63 -0
- data/src/main/java/processing/core/PSurface.java +161 -0
- data/src/main/java/processing/core/PSurfaceNone.java +374 -0
- data/src/main/java/processing/core/PVector.java +1063 -0
- data/src/main/java/processing/data/FloatDict.java +829 -0
- data/src/main/java/processing/data/FloatList.java +912 -0
- data/src/main/java/processing/data/IntDict.java +796 -0
- data/src/main/java/processing/data/IntList.java +913 -0
- data/src/main/java/processing/data/JSONArray.java +1260 -0
- data/src/main/java/processing/data/JSONObject.java +2282 -0
- data/src/main/java/processing/data/JSONTokener.java +435 -0
- data/src/main/java/processing/data/Sort.java +46 -0
- data/src/main/java/processing/data/StringDict.java +601 -0
- data/src/main/java/processing/data/StringList.java +775 -0
- data/src/main/java/processing/data/Table.java +4923 -0
- data/src/main/java/processing/data/TableRow.java +198 -0
- data/src/main/java/processing/data/XML.java +1149 -0
- data/src/main/java/processing/event/Event.java +125 -0
- data/src/main/java/processing/event/KeyEvent.java +70 -0
- data/src/main/java/processing/event/MouseEvent.java +149 -0
- data/src/main/java/processing/event/TouchEvent.java +57 -0
- data/src/main/java/processing/opengl/FontTexture.java +379 -0
- data/src/main/java/processing/opengl/FrameBuffer.java +503 -0
- data/src/main/java/processing/opengl/LinePath.java +623 -0
- data/src/main/java/processing/opengl/LineStroker.java +685 -0
- data/src/main/java/processing/opengl/PGL.java +3366 -0
- data/src/main/java/processing/opengl/PGraphics2D.java +615 -0
- data/src/main/java/processing/opengl/PGraphics3D.java +281 -0
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13634 -0
- data/src/main/java/processing/opengl/PJOGL.java +1966 -0
- data/src/main/java/processing/opengl/PShader.java +1478 -0
- data/src/main/java/processing/opengl/PShapeOpenGL.java +5234 -0
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1315 -0
- data/src/main/java/processing/opengl/Texture.java +1670 -0
- data/src/main/java/processing/opengl/VertexBuffer.java +88 -0
- 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 +27 -0
- 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 +32 -0
- data/src/main/java/processing/opengl/shaders/ColorVert.glsl +34 -0
- data/src/main/java/processing/opengl/shaders/LightFrag.glsl +33 -0
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +154 -0
- data/src/main/java/processing/opengl/shaders/LightVert.glsl +151 -0
- data/src/main/java/processing/opengl/shaders/LineFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/LineVert.glsl +100 -0
- data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
- data/src/main/java/processing/opengl/shaders/PointFrag.glsl +32 -0
- data/src/main/java/processing/opengl/shaders/PointVert.glsl +56 -0
- data/src/main/java/processing/opengl/shaders/TexFrag.glsl +37 -0
- data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +160 -0
- data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
- data/src/main/java/processing/opengl/shaders/TexVert.glsl +38 -0
- data/src/main/resources/icon/icon-1024.png +0 -0
- data/src/main/resources/icon/icon-128.png +0 -0
- data/src/main/resources/icon/icon-16.png +0 -0
- data/src/main/resources/icon/icon-256.png +0 -0
- data/src/main/resources/icon/icon-32.png +0 -0
- data/src/main/resources/icon/icon-48.png +0 -0
- data/src/main/resources/icon/icon-512.png +0 -0
- data/src/main/resources/icon/icon-64.png +0 -0
- data/src/main/resources/license.txt +508 -0
- data/vendors/Rakefile +5 -20
- metadata +115 -33
- data/lib/propane.jar +0 -0
@@ -0,0 +1,877 @@
|
|
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
|
+
public void set(float[] source) {
|
153
|
+
if (source.length == 6) {
|
154
|
+
set(source[0], source[1], source[2],
|
155
|
+
source[3], source[4], source[5]);
|
156
|
+
|
157
|
+
} else if (source.length == 16) {
|
158
|
+
m00 = source[0];
|
159
|
+
m01 = source[1];
|
160
|
+
m02 = source[2];
|
161
|
+
m03 = source[3];
|
162
|
+
|
163
|
+
m10 = source[4];
|
164
|
+
m11 = source[5];
|
165
|
+
m12 = source[6];
|
166
|
+
m13 = source[7];
|
167
|
+
|
168
|
+
m20 = source[8];
|
169
|
+
m21 = source[9];
|
170
|
+
m22 = source[10];
|
171
|
+
m23 = source[11];
|
172
|
+
|
173
|
+
m30 = source[12];
|
174
|
+
m31 = source[13];
|
175
|
+
m32 = source[14];
|
176
|
+
m33 = source[15];
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
public void set(float m00, float m01, float m02,
|
182
|
+
float m10, float m11, float m12) {
|
183
|
+
set(m00, m01, 0, m02,
|
184
|
+
m10, m11, 0, m12,
|
185
|
+
0, 0, 1, 0,
|
186
|
+
0, 0, 0, 1);
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
public void set(float m00, float m01, float m02, float m03,
|
191
|
+
float m10, float m11, float m12, float m13,
|
192
|
+
float m20, float m21, float m22, float m23,
|
193
|
+
float m30, float m31, float m32, float m33) {
|
194
|
+
this.m00 = m00; this.m01 = m01; this.m02 = m02; this.m03 = m03;
|
195
|
+
this.m10 = m10; this.m11 = m11; this.m12 = m12; this.m13 = m13;
|
196
|
+
this.m20 = m20; this.m21 = m21; this.m22 = m22; this.m23 = m23;
|
197
|
+
this.m30 = m30; this.m31 = m31; this.m32 = m32; this.m33 = m33;
|
198
|
+
}
|
199
|
+
|
200
|
+
|
201
|
+
public void translate(float tx, float ty) {
|
202
|
+
translate(tx, ty, 0);
|
203
|
+
}
|
204
|
+
|
205
|
+
// public void invTranslate(float tx, float ty) {
|
206
|
+
// invTranslate(tx, ty, 0);
|
207
|
+
// }
|
208
|
+
|
209
|
+
|
210
|
+
public void translate(float tx, float ty, float tz) {
|
211
|
+
m03 += tx*m00 + ty*m01 + tz*m02;
|
212
|
+
m13 += tx*m10 + ty*m11 + tz*m12;
|
213
|
+
m23 += tx*m20 + ty*m21 + tz*m22;
|
214
|
+
m33 += tx*m30 + ty*m31 + tz*m32;
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
public void rotate(float angle) {
|
219
|
+
rotateZ(angle);
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
public void rotateX(float angle) {
|
224
|
+
float c = cos(angle);
|
225
|
+
float s = sin(angle);
|
226
|
+
apply(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
public void rotateY(float angle) {
|
231
|
+
float c = cos(angle);
|
232
|
+
float s = sin(angle);
|
233
|
+
apply(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
|
234
|
+
}
|
235
|
+
|
236
|
+
|
237
|
+
public void rotateZ(float angle) {
|
238
|
+
float c = cos(angle);
|
239
|
+
float s = sin(angle);
|
240
|
+
apply(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
public void rotate(float angle, float v0, float v1, float v2) {
|
245
|
+
float norm2 = v0 * v0 + v1 * v1 + v2 * v2;
|
246
|
+
if (norm2 < PConstants.EPSILON) {
|
247
|
+
// The vector is zero, cannot apply rotation.
|
248
|
+
return;
|
249
|
+
}
|
250
|
+
|
251
|
+
if (Math.abs(norm2 - 1) > PConstants.EPSILON) {
|
252
|
+
// The rotation vector is not normalized.
|
253
|
+
float norm = PApplet.sqrt(norm2);
|
254
|
+
v0 /= norm;
|
255
|
+
v1 /= norm;
|
256
|
+
v2 /= norm;
|
257
|
+
}
|
258
|
+
|
259
|
+
float c = cos(angle);
|
260
|
+
float s = sin(angle);
|
261
|
+
float t = 1.0f - c;
|
262
|
+
|
263
|
+
apply((t*v0*v0) + c, (t*v0*v1) - (s*v2), (t*v0*v2) + (s*v1), 0,
|
264
|
+
(t*v0*v1) + (s*v2), (t*v1*v1) + c, (t*v1*v2) - (s*v0), 0,
|
265
|
+
(t*v0*v2) - (s*v1), (t*v1*v2) + (s*v0), (t*v2*v2) + c, 0,
|
266
|
+
0, 0, 0, 1);
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
public void scale(float s) {
|
271
|
+
//apply(s, 0, 0, 0, 0, s, 0, 0, 0, 0, s, 0, 0, 0, 0, 1);
|
272
|
+
scale(s, s, s);
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
public void scale(float sx, float sy) {
|
277
|
+
//apply(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
278
|
+
scale(sx, sy, 1);
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
public void scale(float x, float y, float z) {
|
283
|
+
//apply(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
|
284
|
+
m00 *= x; m01 *= y; m02 *= z;
|
285
|
+
m10 *= x; m11 *= y; m12 *= z;
|
286
|
+
m20 *= x; m21 *= y; m22 *= z;
|
287
|
+
m30 *= x; m31 *= y; m32 *= z;
|
288
|
+
}
|
289
|
+
|
290
|
+
|
291
|
+
public void shearX(float angle) {
|
292
|
+
float t = (float) Math.tan(angle);
|
293
|
+
apply(1, t, 0, 0,
|
294
|
+
0, 1, 0, 0,
|
295
|
+
0, 0, 1, 0,
|
296
|
+
0, 0, 0, 1);
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
public void shearY(float angle) {
|
301
|
+
float t = (float) Math.tan(angle);
|
302
|
+
apply(1, 0, 0, 0,
|
303
|
+
t, 1, 0, 0,
|
304
|
+
0, 0, 1, 0,
|
305
|
+
0, 0, 0, 1);
|
306
|
+
}
|
307
|
+
|
308
|
+
|
309
|
+
public void apply(PMatrix source) {
|
310
|
+
if (source instanceof PMatrix2D) {
|
311
|
+
apply((PMatrix2D) source);
|
312
|
+
} else if (source instanceof PMatrix3D) {
|
313
|
+
apply((PMatrix3D) source);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
public void apply(PMatrix2D source) {
|
319
|
+
apply(source.m00, source.m01, 0, source.m02,
|
320
|
+
source.m10, source.m11, 0, source.m12,
|
321
|
+
0, 0, 1, 0,
|
322
|
+
0, 0, 0, 1);
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
public void apply(PMatrix3D source) {
|
327
|
+
apply(source.m00, source.m01, source.m02, source.m03,
|
328
|
+
source.m10, source.m11, source.m12, source.m13,
|
329
|
+
source.m20, source.m21, source.m22, source.m23,
|
330
|
+
source.m30, source.m31, source.m32, source.m33);
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
public void apply(float n00, float n01, float n02,
|
335
|
+
float n10, float n11, float n12) {
|
336
|
+
apply(n00, n01, 0, n02,
|
337
|
+
n10, n11, 0, n12,
|
338
|
+
0, 0, 1, 0,
|
339
|
+
0, 0, 0, 1);
|
340
|
+
}
|
341
|
+
|
342
|
+
|
343
|
+
public void apply(float n00, float n01, float n02, float n03,
|
344
|
+
float n10, float n11, float n12, float n13,
|
345
|
+
float n20, float n21, float n22, float n23,
|
346
|
+
float n30, float n31, float n32, float n33) {
|
347
|
+
|
348
|
+
float r00 = m00*n00 + m01*n10 + m02*n20 + m03*n30;
|
349
|
+
float r01 = m00*n01 + m01*n11 + m02*n21 + m03*n31;
|
350
|
+
float r02 = m00*n02 + m01*n12 + m02*n22 + m03*n32;
|
351
|
+
float r03 = m00*n03 + m01*n13 + m02*n23 + m03*n33;
|
352
|
+
|
353
|
+
float r10 = m10*n00 + m11*n10 + m12*n20 + m13*n30;
|
354
|
+
float r11 = m10*n01 + m11*n11 + m12*n21 + m13*n31;
|
355
|
+
float r12 = m10*n02 + m11*n12 + m12*n22 + m13*n32;
|
356
|
+
float r13 = m10*n03 + m11*n13 + m12*n23 + m13*n33;
|
357
|
+
|
358
|
+
float r20 = m20*n00 + m21*n10 + m22*n20 + m23*n30;
|
359
|
+
float r21 = m20*n01 + m21*n11 + m22*n21 + m23*n31;
|
360
|
+
float r22 = m20*n02 + m21*n12 + m22*n22 + m23*n32;
|
361
|
+
float r23 = m20*n03 + m21*n13 + m22*n23 + m23*n33;
|
362
|
+
|
363
|
+
float r30 = m30*n00 + m31*n10 + m32*n20 + m33*n30;
|
364
|
+
float r31 = m30*n01 + m31*n11 + m32*n21 + m33*n31;
|
365
|
+
float r32 = m30*n02 + m31*n12 + m32*n22 + m33*n32;
|
366
|
+
float r33 = m30*n03 + m31*n13 + m32*n23 + m33*n33;
|
367
|
+
|
368
|
+
m00 = r00; m01 = r01; m02 = r02; m03 = r03;
|
369
|
+
m10 = r10; m11 = r11; m12 = r12; m13 = r13;
|
370
|
+
m20 = r20; m21 = r21; m22 = r22; m23 = r23;
|
371
|
+
m30 = r30; m31 = r31; m32 = r32; m33 = r33;
|
372
|
+
}
|
373
|
+
|
374
|
+
|
375
|
+
/**
|
376
|
+
* Apply the 3D equivalent of the 2D matrix supplied to the left of this one.
|
377
|
+
*/
|
378
|
+
public void preApply(PMatrix2D left) {
|
379
|
+
preApply(left.m00, left.m01, 0, left.m02,
|
380
|
+
left.m10, left.m11, 0, left.m12,
|
381
|
+
0, 0, 1, 0,
|
382
|
+
0, 0, 0, 1);
|
383
|
+
}
|
384
|
+
|
385
|
+
|
386
|
+
/**
|
387
|
+
* Apply another matrix to the left of this one.
|
388
|
+
*/
|
389
|
+
public void preApply(PMatrix source) {
|
390
|
+
if (source instanceof PMatrix2D) {
|
391
|
+
preApply((PMatrix2D) source);
|
392
|
+
} else if (source instanceof PMatrix3D) {
|
393
|
+
preApply((PMatrix3D) source);
|
394
|
+
}
|
395
|
+
}
|
396
|
+
|
397
|
+
|
398
|
+
/**
|
399
|
+
* Apply another matrix to the left of this one.
|
400
|
+
*/
|
401
|
+
public void preApply(PMatrix3D left) {
|
402
|
+
preApply(left.m00, left.m01, left.m02, left.m03,
|
403
|
+
left.m10, left.m11, left.m12, left.m13,
|
404
|
+
left.m20, left.m21, left.m22, left.m23,
|
405
|
+
left.m30, left.m31, left.m32, left.m33);
|
406
|
+
}
|
407
|
+
|
408
|
+
|
409
|
+
/**
|
410
|
+
* Apply the 3D equivalent of the 2D matrix supplied to the left of this one.
|
411
|
+
*/
|
412
|
+
public void preApply(float n00, float n01, float n02,
|
413
|
+
float n10, float n11, float n12) {
|
414
|
+
preApply(n00, n01, 0, n02,
|
415
|
+
n10, n11, 0, n12,
|
416
|
+
0, 0, 1, 0,
|
417
|
+
0, 0, 0, 1);
|
418
|
+
}
|
419
|
+
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Apply another matrix to the left of this one.
|
423
|
+
*/
|
424
|
+
public void preApply(float n00, float n01, float n02, float n03,
|
425
|
+
float n10, float n11, float n12, float n13,
|
426
|
+
float n20, float n21, float n22, float n23,
|
427
|
+
float n30, float n31, float n32, float n33) {
|
428
|
+
|
429
|
+
float r00 = n00*m00 + n01*m10 + n02*m20 + n03*m30;
|
430
|
+
float r01 = n00*m01 + n01*m11 + n02*m21 + n03*m31;
|
431
|
+
float r02 = n00*m02 + n01*m12 + n02*m22 + n03*m32;
|
432
|
+
float r03 = n00*m03 + n01*m13 + n02*m23 + n03*m33;
|
433
|
+
|
434
|
+
float r10 = n10*m00 + n11*m10 + n12*m20 + n13*m30;
|
435
|
+
float r11 = n10*m01 + n11*m11 + n12*m21 + n13*m31;
|
436
|
+
float r12 = n10*m02 + n11*m12 + n12*m22 + n13*m32;
|
437
|
+
float r13 = n10*m03 + n11*m13 + n12*m23 + n13*m33;
|
438
|
+
|
439
|
+
float r20 = n20*m00 + n21*m10 + n22*m20 + n23*m30;
|
440
|
+
float r21 = n20*m01 + n21*m11 + n22*m21 + n23*m31;
|
441
|
+
float r22 = n20*m02 + n21*m12 + n22*m22 + n23*m32;
|
442
|
+
float r23 = n20*m03 + n21*m13 + n22*m23 + n23*m33;
|
443
|
+
|
444
|
+
float r30 = n30*m00 + n31*m10 + n32*m20 + n33*m30;
|
445
|
+
float r31 = n30*m01 + n31*m11 + n32*m21 + n33*m31;
|
446
|
+
float r32 = n30*m02 + n31*m12 + n32*m22 + n33*m32;
|
447
|
+
float r33 = n30*m03 + n31*m13 + n32*m23 + n33*m33;
|
448
|
+
|
449
|
+
m00 = r00; m01 = r01; m02 = r02; m03 = r03;
|
450
|
+
m10 = r10; m11 = r11; m12 = r12; m13 = r13;
|
451
|
+
m20 = r20; m21 = r21; m22 = r22; m23 = r23;
|
452
|
+
m30 = r30; m31 = r31; m32 = r32; m33 = r33;
|
453
|
+
}
|
454
|
+
|
455
|
+
|
456
|
+
//////////////////////////////////////////////////////////////
|
457
|
+
|
458
|
+
|
459
|
+
/**
|
460
|
+
* Multiply source by this matrix, and return the result.
|
461
|
+
* The result will be stored in target if target is non-null, and target
|
462
|
+
* will then be the matrix returned. This improves performance if you reuse
|
463
|
+
* target, so it's recommended if you call this many times in draw().
|
464
|
+
*/
|
465
|
+
public PVector mult(PVector source, PVector target) {
|
466
|
+
if (target == null) {
|
467
|
+
target = new PVector();
|
468
|
+
}
|
469
|
+
target.set(m00*source.x + m01*source.y + m02*source.z + m03,
|
470
|
+
m10*source.x + m11*source.y + m12*source.z + m13,
|
471
|
+
m20*source.x + m21*source.y + m22*source.z + m23);
|
472
|
+
// float tw = m30*source.x + m31*source.y + m32*source.z + m33;
|
473
|
+
// if (tw != 0 && tw != 1) {
|
474
|
+
// target.div(tw);
|
475
|
+
// }
|
476
|
+
return target;
|
477
|
+
}
|
478
|
+
|
479
|
+
|
480
|
+
/*
|
481
|
+
public PVector cmult(PVector source, PVector target) {
|
482
|
+
if (target == null) {
|
483
|
+
target = new PVector();
|
484
|
+
}
|
485
|
+
target.x = m00*source.x + m10*source.y + m20*source.z + m30;
|
486
|
+
target.y = m01*source.x + m11*source.y + m21*source.z + m31;
|
487
|
+
target.z = m02*source.x + m12*source.y + m22*source.z + m32;
|
488
|
+
float tw = m03*source.x + m13*source.y + m23*source.z + m33;
|
489
|
+
if (tw != 0 && tw != 1) {
|
490
|
+
target.div(tw);
|
491
|
+
}
|
492
|
+
return target;
|
493
|
+
}
|
494
|
+
*/
|
495
|
+
|
496
|
+
|
497
|
+
/**
|
498
|
+
* Multiply a three or four element vector against this matrix. If out is
|
499
|
+
* null or not length 3 or 4, a new float array (length 3) will be returned.
|
500
|
+
* Supplying and recycling a target array improves performance, so it's
|
501
|
+
* recommended if you call this many times in draw.
|
502
|
+
*/
|
503
|
+
public float[] mult(float[] source, float[] target) {
|
504
|
+
if (target == null || target.length < 3) {
|
505
|
+
target = new float[3];
|
506
|
+
}
|
507
|
+
if (source == target) {
|
508
|
+
throw new RuntimeException("The source and target vectors used in " +
|
509
|
+
"PMatrix3D.mult() cannot be identical.");
|
510
|
+
}
|
511
|
+
if (target.length == 3) {
|
512
|
+
target[0] = m00*source[0] + m01*source[1] + m02*source[2] + m03;
|
513
|
+
target[1] = m10*source[0] + m11*source[1] + m12*source[2] + m13;
|
514
|
+
target[2] = m20*source[0] + m21*source[1] + m22*source[2] + m23;
|
515
|
+
//float w = m30*source[0] + m31*source[1] + m32*source[2] + m33;
|
516
|
+
//if (w != 0 && w != 1) {
|
517
|
+
// target[0] /= w; target[1] /= w; target[2] /= w;
|
518
|
+
//}
|
519
|
+
} else if (target.length > 3) {
|
520
|
+
target[0] = m00*source[0] + m01*source[1] + m02*source[2] + m03*source[3];
|
521
|
+
target[1] = m10*source[0] + m11*source[1] + m12*source[2] + m13*source[3];
|
522
|
+
target[2] = m20*source[0] + m21*source[1] + m22*source[2] + m23*source[3];
|
523
|
+
target[3] = m30*source[0] + m31*source[1] + m32*source[2] + m33*source[3];
|
524
|
+
}
|
525
|
+
return target;
|
526
|
+
}
|
527
|
+
|
528
|
+
|
529
|
+
/**
|
530
|
+
* Returns the x-coordinate of the result of multiplying the point (x, y)
|
531
|
+
* by this matrix.
|
532
|
+
*/
|
533
|
+
public float multX(float x, float y) {
|
534
|
+
return m00*x + m01*y + m03;
|
535
|
+
}
|
536
|
+
|
537
|
+
|
538
|
+
/**
|
539
|
+
* Returns the y-coordinate of the result of multiplying the point (x, y)
|
540
|
+
* by this matrix.
|
541
|
+
*/
|
542
|
+
public float multY(float x, float y) {
|
543
|
+
return m10*x + m11*y + m13;
|
544
|
+
}
|
545
|
+
|
546
|
+
|
547
|
+
/**
|
548
|
+
* Returns the x-coordinate of the result of multiplying the point (x, y, z)
|
549
|
+
* by this matrix.
|
550
|
+
*/
|
551
|
+
public float multX(float x, float y, float z) {
|
552
|
+
return m00*x + m01*y + m02*z + m03;
|
553
|
+
}
|
554
|
+
|
555
|
+
|
556
|
+
/**
|
557
|
+
* Returns the y-coordinate of the result of multiplying the point (x, y, z)
|
558
|
+
* by this matrix.
|
559
|
+
*/
|
560
|
+
public float multY(float x, float y, float z) {
|
561
|
+
return m10*x + m11*y + m12*z + m13;
|
562
|
+
}
|
563
|
+
|
564
|
+
|
565
|
+
/**
|
566
|
+
* Returns the z-coordinate of the result of multiplying the point (x, y, z)
|
567
|
+
* by this matrix.
|
568
|
+
*/
|
569
|
+
public float multZ(float x, float y, float z) {
|
570
|
+
return m20*x + m21*y + m22*z + m23;
|
571
|
+
}
|
572
|
+
|
573
|
+
|
574
|
+
/**
|
575
|
+
* Returns the fourth element of the result of multiplying the vector
|
576
|
+
* (x, y, z) by this matrix. (Acts as if w = 1 was supplied.)
|
577
|
+
*/
|
578
|
+
public float multW(float x, float y, float z) {
|
579
|
+
return m30*x + m31*y + m32*z + m33;
|
580
|
+
}
|
581
|
+
|
582
|
+
|
583
|
+
/**
|
584
|
+
* Returns the x-coordinate of the result of multiplying the vector
|
585
|
+
* (x, y, z, w) by this matrix.
|
586
|
+
*/
|
587
|
+
public float multX(float x, float y, float z, float w) {
|
588
|
+
return m00*x + m01*y + m02*z + m03*w;
|
589
|
+
}
|
590
|
+
|
591
|
+
|
592
|
+
/**
|
593
|
+
* Returns the y-coordinate of the result of multiplying the vector
|
594
|
+
* (x, y, z, w) by this matrix.
|
595
|
+
*/
|
596
|
+
public float multY(float x, float y, float z, float w) {
|
597
|
+
return m10*x + m11*y + m12*z + m13*w;
|
598
|
+
}
|
599
|
+
|
600
|
+
|
601
|
+
/**
|
602
|
+
* Returns the z-coordinate of the result of multiplying the vector
|
603
|
+
* (x, y, z, w) by this matrix.
|
604
|
+
*/
|
605
|
+
public float multZ(float x, float y, float z, float w) {
|
606
|
+
return m20*x + m21*y + m22*z + m23*w;
|
607
|
+
}
|
608
|
+
|
609
|
+
|
610
|
+
/**
|
611
|
+
* Returns the w-coordinate of the result of multiplying the vector
|
612
|
+
* (x, y, z, w) by this matrix.
|
613
|
+
*/
|
614
|
+
public float multW(float x, float y, float z, float w) {
|
615
|
+
return m30*x + m31*y + m32*z + m33*w;
|
616
|
+
}
|
617
|
+
|
618
|
+
|
619
|
+
/**
|
620
|
+
* Transpose this matrix; rows become columns and columns rows.
|
621
|
+
*/
|
622
|
+
public void transpose() {
|
623
|
+
float temp;
|
624
|
+
temp = m01; m01 = m10; m10 = temp;
|
625
|
+
temp = m02; m02 = m20; m20 = temp;
|
626
|
+
temp = m03; m03 = m30; m30 = temp;
|
627
|
+
temp = m12; m12 = m21; m21 = temp;
|
628
|
+
temp = m13; m13 = m31; m31 = temp;
|
629
|
+
temp = m23; m23 = m32; m32 = temp;
|
630
|
+
}
|
631
|
+
|
632
|
+
|
633
|
+
/**
|
634
|
+
* Invert this matrix. Will not necessarily succeed, because some matrices
|
635
|
+
* map more than one point to the same image point, and so are irreversible.
|
636
|
+
* @return true if successful
|
637
|
+
*/
|
638
|
+
public boolean invert() {
|
639
|
+
float determinant = determinant();
|
640
|
+
if (determinant == 0) {
|
641
|
+
return false;
|
642
|
+
}
|
643
|
+
|
644
|
+
// first row
|
645
|
+
float t00 = determinant3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33);
|
646
|
+
float t01 = -determinant3x3(m10, m12, m13, m20, m22, m23, m30, m32, m33);
|
647
|
+
float t02 = determinant3x3(m10, m11, m13, m20, m21, m23, m30, m31, m33);
|
648
|
+
float t03 = -determinant3x3(m10, m11, m12, m20, m21, m22, m30, m31, m32);
|
649
|
+
|
650
|
+
// second row
|
651
|
+
float t10 = -determinant3x3(m01, m02, m03, m21, m22, m23, m31, m32, m33);
|
652
|
+
float t11 = determinant3x3(m00, m02, m03, m20, m22, m23, m30, m32, m33);
|
653
|
+
float t12 = -determinant3x3(m00, m01, m03, m20, m21, m23, m30, m31, m33);
|
654
|
+
float t13 = determinant3x3(m00, m01, m02, m20, m21, m22, m30, m31, m32);
|
655
|
+
|
656
|
+
// third row
|
657
|
+
float t20 = determinant3x3(m01, m02, m03, m11, m12, m13, m31, m32, m33);
|
658
|
+
float t21 = -determinant3x3(m00, m02, m03, m10, m12, m13, m30, m32, m33);
|
659
|
+
float t22 = determinant3x3(m00, m01, m03, m10, m11, m13, m30, m31, m33);
|
660
|
+
float t23 = -determinant3x3(m00, m01, m02, m10, m11, m12, m30, m31, m32);
|
661
|
+
|
662
|
+
// fourth row
|
663
|
+
float t30 = -determinant3x3(m01, m02, m03, m11, m12, m13, m21, m22, m23);
|
664
|
+
float t31 = determinant3x3(m00, m02, m03, m10, m12, m13, m20, m22, m23);
|
665
|
+
float t32 = -determinant3x3(m00, m01, m03, m10, m11, m13, m20, m21, m23);
|
666
|
+
float t33 = determinant3x3(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
667
|
+
|
668
|
+
// transpose and divide by the determinant
|
669
|
+
m00 = t00 / determinant;
|
670
|
+
m01 = t10 / determinant;
|
671
|
+
m02 = t20 / determinant;
|
672
|
+
m03 = t30 / determinant;
|
673
|
+
|
674
|
+
m10 = t01 / determinant;
|
675
|
+
m11 = t11 / determinant;
|
676
|
+
m12 = t21 / determinant;
|
677
|
+
m13 = t31 / determinant;
|
678
|
+
|
679
|
+
m20 = t02 / determinant;
|
680
|
+
m21 = t12 / determinant;
|
681
|
+
m22 = t22 / determinant;
|
682
|
+
m23 = t32 / determinant;
|
683
|
+
|
684
|
+
m30 = t03 / determinant;
|
685
|
+
m31 = t13 / determinant;
|
686
|
+
m32 = t23 / determinant;
|
687
|
+
m33 = t33 / determinant;
|
688
|
+
|
689
|
+
return true;
|
690
|
+
}
|
691
|
+
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Calculate the determinant of a 3x3 matrix.
|
695
|
+
* @return result
|
696
|
+
*/
|
697
|
+
private float determinant3x3(float t00, float t01, float t02,
|
698
|
+
float t10, float t11, float t12,
|
699
|
+
float t20, float t21, float t22) {
|
700
|
+
return (t00 * (t11 * t22 - t12 * t21) +
|
701
|
+
t01 * (t12 * t20 - t10 * t22) +
|
702
|
+
t02 * (t10 * t21 - t11 * t20));
|
703
|
+
}
|
704
|
+
|
705
|
+
|
706
|
+
/**
|
707
|
+
* @return the determinant of the matrix
|
708
|
+
*/
|
709
|
+
public float determinant() {
|
710
|
+
float f =
|
711
|
+
m00
|
712
|
+
* ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32)
|
713
|
+
- m13 * m22 * m31
|
714
|
+
- m11 * m23 * m32
|
715
|
+
- m12 * m21 * m33);
|
716
|
+
f -= m01
|
717
|
+
* ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32)
|
718
|
+
- m13 * m22 * m30
|
719
|
+
- m10 * m23 * m32
|
720
|
+
- m12 * m20 * m33);
|
721
|
+
f += m02
|
722
|
+
* ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31)
|
723
|
+
- m13 * m21 * m30
|
724
|
+
- m10 * m23 * m31
|
725
|
+
- m11 * m20 * m33);
|
726
|
+
f -= m03
|
727
|
+
* ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31)
|
728
|
+
- m12 * m21 * m30
|
729
|
+
- m10 * m22 * m31
|
730
|
+
- m11 * m20 * m32);
|
731
|
+
return f;
|
732
|
+
}
|
733
|
+
|
734
|
+
|
735
|
+
//////////////////////////////////////////////////////////////
|
736
|
+
|
737
|
+
// REVERSE VERSIONS OF MATRIX OPERATIONS
|
738
|
+
|
739
|
+
// These functions should not be used, as they will be removed in the future.
|
740
|
+
|
741
|
+
|
742
|
+
protected void invTranslate(float tx, float ty, float tz) {
|
743
|
+
preApply(1, 0, 0, -tx,
|
744
|
+
0, 1, 0, -ty,
|
745
|
+
0, 0, 1, -tz,
|
746
|
+
0, 0, 0, 1);
|
747
|
+
}
|
748
|
+
|
749
|
+
|
750
|
+
protected void invRotateX(float angle) {
|
751
|
+
float c = cos(-angle);
|
752
|
+
float s = sin(-angle);
|
753
|
+
preApply(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
|
754
|
+
}
|
755
|
+
|
756
|
+
|
757
|
+
protected void invRotateY(float angle) {
|
758
|
+
float c = cos(-angle);
|
759
|
+
float s = sin(-angle);
|
760
|
+
preApply(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
|
761
|
+
}
|
762
|
+
|
763
|
+
|
764
|
+
protected void invRotateZ(float angle) {
|
765
|
+
float c = cos(-angle);
|
766
|
+
float s = sin(-angle);
|
767
|
+
preApply(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
768
|
+
}
|
769
|
+
|
770
|
+
|
771
|
+
protected void invRotate(float angle, float v0, float v1, float v2) {
|
772
|
+
//TODO should make sure this vector is normalized
|
773
|
+
|
774
|
+
float c = cos(-angle);
|
775
|
+
float s = sin(-angle);
|
776
|
+
float t = 1.0f - c;
|
777
|
+
|
778
|
+
preApply((t*v0*v0) + c, (t*v0*v1) - (s*v2), (t*v0*v2) + (s*v1), 0,
|
779
|
+
(t*v0*v1) + (s*v2), (t*v1*v1) + c, (t*v1*v2) - (s*v0), 0,
|
780
|
+
(t*v0*v2) - (s*v1), (t*v1*v2) + (s*v0), (t*v2*v2) + c, 0,
|
781
|
+
0, 0, 0, 1);
|
782
|
+
}
|
783
|
+
|
784
|
+
|
785
|
+
protected void invScale(float x, float y, float z) {
|
786
|
+
preApply(1/x, 0, 0, 0, 0, 1/y, 0, 0, 0, 0, 1/z, 0, 0, 0, 0, 1);
|
787
|
+
}
|
788
|
+
|
789
|
+
|
790
|
+
protected boolean invApply(float n00, float n01, float n02, float n03,
|
791
|
+
float n10, float n11, float n12, float n13,
|
792
|
+
float n20, float n21, float n22, float n23,
|
793
|
+
float n30, float n31, float n32, float n33) {
|
794
|
+
if (inverseCopy == null) {
|
795
|
+
inverseCopy = new PMatrix3D();
|
796
|
+
}
|
797
|
+
inverseCopy.set(n00, n01, n02, n03,
|
798
|
+
n10, n11, n12, n13,
|
799
|
+
n20, n21, n22, n23,
|
800
|
+
n30, n31, n32, n33);
|
801
|
+
if (!inverseCopy.invert()) {
|
802
|
+
return false;
|
803
|
+
}
|
804
|
+
preApply(inverseCopy);
|
805
|
+
return true;
|
806
|
+
}
|
807
|
+
|
808
|
+
|
809
|
+
//////////////////////////////////////////////////////////////
|
810
|
+
|
811
|
+
|
812
|
+
public void print() {
|
813
|
+
/*
|
814
|
+
System.out.println(m00 + " " + m01 + " " + m02 + " " + m03 + "\n" +
|
815
|
+
m10 + " " + m11 + " " + m12 + " " + m13 + "\n" +
|
816
|
+
m20 + " " + m21 + " " + m22 + " " + m23 + "\n" +
|
817
|
+
m30 + " " + m31 + " " + m32 + " " + m33 + "\n");
|
818
|
+
*/
|
819
|
+
int big = (int) Math.abs(max(max(max(max(abs(m00), abs(m01)),
|
820
|
+
max(abs(m02), abs(m03))),
|
821
|
+
max(max(abs(m10), abs(m11)),
|
822
|
+
max(abs(m12), abs(m13)))),
|
823
|
+
max(max(max(abs(m20), abs(m21)),
|
824
|
+
max(abs(m22), abs(m23))),
|
825
|
+
max(max(abs(m30), abs(m31)),
|
826
|
+
max(abs(m32), abs(m33))))));
|
827
|
+
|
828
|
+
int digits = 1;
|
829
|
+
if (Float.isNaN(big) || Float.isInfinite(big)) { // avoid infinite loop
|
830
|
+
digits = 5;
|
831
|
+
} else {
|
832
|
+
while ((big /= 10) != 0) digits++; // cheap log()
|
833
|
+
}
|
834
|
+
|
835
|
+
System.out.println(PApplet.nfs(m00, digits, 4) + " " +
|
836
|
+
PApplet.nfs(m01, digits, 4) + " " +
|
837
|
+
PApplet.nfs(m02, digits, 4) + " " +
|
838
|
+
PApplet.nfs(m03, digits, 4));
|
839
|
+
|
840
|
+
System.out.println(PApplet.nfs(m10, digits, 4) + " " +
|
841
|
+
PApplet.nfs(m11, digits, 4) + " " +
|
842
|
+
PApplet.nfs(m12, digits, 4) + " " +
|
843
|
+
PApplet.nfs(m13, digits, 4));
|
844
|
+
|
845
|
+
System.out.println(PApplet.nfs(m20, digits, 4) + " " +
|
846
|
+
PApplet.nfs(m21, digits, 4) + " " +
|
847
|
+
PApplet.nfs(m22, digits, 4) + " " +
|
848
|
+
PApplet.nfs(m23, digits, 4));
|
849
|
+
|
850
|
+
System.out.println(PApplet.nfs(m30, digits, 4) + " " +
|
851
|
+
PApplet.nfs(m31, digits, 4) + " " +
|
852
|
+
PApplet.nfs(m32, digits, 4) + " " +
|
853
|
+
PApplet.nfs(m33, digits, 4));
|
854
|
+
|
855
|
+
System.out.println();
|
856
|
+
}
|
857
|
+
|
858
|
+
|
859
|
+
//////////////////////////////////////////////////////////////
|
860
|
+
|
861
|
+
|
862
|
+
static private final float max(float a, float b) {
|
863
|
+
return (a > b) ? a : b;
|
864
|
+
}
|
865
|
+
|
866
|
+
static private final float abs(float a) {
|
867
|
+
return (a < 0) ? -a : a;
|
868
|
+
}
|
869
|
+
|
870
|
+
static private final float sin(float angle) {
|
871
|
+
return (float) Math.sin(angle);
|
872
|
+
}
|
873
|
+
|
874
|
+
static private final float cos(float angle) {
|
875
|
+
return (float) Math.cos(angle);
|
876
|
+
}
|
877
|
+
}
|