toxiclibs 0.9.1 → 0.9.2
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +6 -4
- data/examples/boolean_shapes.rb +46 -0
- data/lib/toxiclibs/version.rb +1 -1
- data/pom.rb +2 -8
- data/pom.xml +2 -14
- data/src/BooleanShapes.java +66 -0
- data/src/toxi/color/ColorList.java +70 -60
- data/src/toxi/color/ColorTheme.java +1 -1
- data/src/toxi/color/Histogram.java +1 -0
- data/src/toxi/color/Hue.java +7 -7
- data/src/toxi/color/TColor.java +31 -24
- data/src/toxi/geom/AxisAlignedCylinder.java +1 -0
- data/src/toxi/geom/BezierCurve2D.java +1 -1
- data/src/toxi/geom/BezierCurve3D.java +1 -1
- data/src/toxi/geom/BooleanShapeBuilder.java +9 -7
- data/src/toxi/geom/Matrix3d.java +293 -381
- data/src/toxi/geom/Matrix4f.java +447 -568
- data/src/toxi/geom/Matrix4x4.java +42 -47
- data/src/toxi/geom/Quaternion.java +52 -71
- data/toxiclibs.gemspec +6 -8
- metadata +7 -28
- data/src/toxi/audio/AudioBuffer.java +0 -229
- data/src/toxi/audio/AudioSource.java +0 -288
- data/src/toxi/audio/DecompressInputStream.java +0 -159
- data/src/toxi/audio/IIRFilter.java +0 -197
- data/src/toxi/audio/JOALUtil.java +0 -388
- data/src/toxi/audio/MultiTimbralManager.java +0 -162
- data/src/toxi/audio/SoundListener.java +0 -154
- data/src/toxi/audio/SynthUtil.java +0 -109
data/src/toxi/color/Hue.java
CHANGED
@@ -41,12 +41,12 @@ public class Hue {
|
|
41
41
|
/**
|
42
42
|
*
|
43
43
|
*/
|
44
|
-
protected static final HashMap<String, Hue>
|
44
|
+
protected static final HashMap<String, Hue> NAMED_HUES = new HashMap<>();
|
45
45
|
|
46
46
|
/**
|
47
47
|
*
|
48
48
|
*/
|
49
|
-
protected static final ArrayList<Hue>
|
49
|
+
protected static final ArrayList<Hue> PRIMARY_HUES = new ArrayList<>();
|
50
50
|
|
51
51
|
/**
|
52
52
|
*
|
@@ -127,7 +127,7 @@ public class Hue {
|
|
127
127
|
hue %= 1;
|
128
128
|
float dist = Float.MAX_VALUE;
|
129
129
|
Hue closest = null;
|
130
|
-
Iterable<Hue> hues = (primaryOnly ?
|
130
|
+
Iterable<Hue> hues = (primaryOnly ? PRIMARY_HUES : NAMED_HUES.values());
|
131
131
|
for (Hue h : hues) {
|
132
132
|
float d = MathUtils.min(MathUtils.abs(h.hue - hue),
|
133
133
|
MathUtils.abs(1 + h.hue - hue));
|
@@ -145,7 +145,7 @@ public class Hue {
|
|
145
145
|
* @return
|
146
146
|
*/
|
147
147
|
public static final Hue getForName(String name) {
|
148
|
-
return
|
148
|
+
return NAMED_HUES.get(name.toLowerCase());
|
149
149
|
}
|
150
150
|
|
151
151
|
/**
|
@@ -165,7 +165,7 @@ public class Hue {
|
|
165
165
|
*/
|
166
166
|
public static boolean isPrimary(float hue, float variance) {
|
167
167
|
boolean isPrimary = false;
|
168
|
-
for (Hue h :
|
168
|
+
for (Hue h : PRIMARY_HUES) {
|
169
169
|
if (MathUtils.abs(hue - h.hue) < variance) {
|
170
170
|
isPrimary = true;
|
171
171
|
break;
|
@@ -208,9 +208,9 @@ public class Hue {
|
|
208
208
|
this.name = name;
|
209
209
|
this.hue = hue;
|
210
210
|
this.isPrimary = isPrimary;
|
211
|
-
|
211
|
+
NAMED_HUES.put(name, this);
|
212
212
|
if (isPrimary) {
|
213
|
-
|
213
|
+
PRIMARY_HUES.add(this);
|
214
214
|
}
|
215
215
|
}
|
216
216
|
|
data/src/toxi/color/TColor.java
CHANGED
@@ -223,30 +223,37 @@ public class TColor implements ReadonlyTColor {
|
|
223
223
|
float q = v * (1 - s * f);
|
224
224
|
float t = v * (1 - s * (1 - f));
|
225
225
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
226
|
+
switch (i) {
|
227
|
+
case 0:
|
228
|
+
rgb[0] = v;
|
229
|
+
rgb[1] = t;
|
230
|
+
rgb[2] = p;
|
231
|
+
break;
|
232
|
+
case 1:
|
233
|
+
rgb[0] = q;
|
234
|
+
rgb[1] = v;
|
235
|
+
rgb[2] = p;
|
236
|
+
break;
|
237
|
+
case 2:
|
238
|
+
rgb[0] = p;
|
239
|
+
rgb[1] = v;
|
240
|
+
rgb[2] = t;
|
241
|
+
break;
|
242
|
+
case 3:
|
243
|
+
rgb[0] = p;
|
244
|
+
rgb[1] = q;
|
245
|
+
rgb[2] = v;
|
246
|
+
break;
|
247
|
+
case 4:
|
248
|
+
rgb[0] = t;
|
249
|
+
rgb[1] = p;
|
250
|
+
rgb[2] = v;
|
251
|
+
break;
|
252
|
+
default:
|
253
|
+
rgb[0] = v;
|
254
|
+
rgb[1] = p;
|
255
|
+
rgb[2] = q;
|
256
|
+
break;
|
250
257
|
}
|
251
258
|
}
|
252
259
|
return rgb;
|
@@ -24,17 +24,14 @@ public class BooleanShapeBuilder {
|
|
24
24
|
*
|
25
25
|
*/
|
26
26
|
UNION,
|
27
|
-
|
28
27
|
/**
|
29
28
|
*
|
30
29
|
*/
|
31
30
|
INTERSECTION,
|
32
|
-
|
33
31
|
/**
|
34
32
|
*
|
35
33
|
*/
|
36
34
|
DIFFERENCE,
|
37
|
-
|
38
35
|
/**
|
39
36
|
*
|
40
37
|
*/
|
@@ -102,13 +99,14 @@ public class BooleanShapeBuilder {
|
|
102
99
|
* @return
|
103
100
|
*/
|
104
101
|
public List<Polygon2D> computeShapes() {
|
105
|
-
List<Polygon2D> shapes = new ArrayList
|
102
|
+
List<Polygon2D> shapes = new ArrayList<>();
|
106
103
|
PathIterator i = area.getPathIterator(null);
|
107
104
|
float[] buf = new float[6];
|
108
105
|
Vec2D prev = new Vec2D();
|
109
106
|
Polygon2D s = null;
|
110
107
|
while (!i.isDone()) {
|
111
108
|
int id = i.currentSegment(buf);
|
109
|
+
|
112
110
|
switch (id) {
|
113
111
|
case PathIterator.SEG_MOVETO:
|
114
112
|
s = new Polygon2D();
|
@@ -118,15 +116,19 @@ public class BooleanShapeBuilder {
|
|
118
116
|
break;
|
119
117
|
case PathIterator.SEG_LINETO:
|
120
118
|
prev.set(buf[0], buf[1]);
|
121
|
-
s
|
119
|
+
if (s != null) {
|
120
|
+
s.add(prev.copy());
|
121
|
+
}
|
122
122
|
break;
|
123
123
|
case PathIterator.SEG_CUBICTO:
|
124
124
|
Vec2D pa = new Vec2D(buf[0], buf[1]);
|
125
125
|
Vec2D pb = new Vec2D(buf[2], buf[3]);
|
126
126
|
Vec2D pc = new Vec2D(buf[4], buf[5]);
|
127
127
|
for (int t = 0; t <= bezierRes; t++) {
|
128
|
-
s
|
129
|
-
|
128
|
+
if (s != null) {
|
129
|
+
s.add(BezierCurve2D.computePointInSegment(prev, pa,
|
130
|
+
pb, pc, (float) t / bezierRes));
|
131
|
+
}
|
130
132
|
}
|
131
133
|
prev.set(pc);
|
132
134
|
break;
|
data/src/toxi/geom/Matrix3d.java
CHANGED
@@ -1,34 +1,33 @@
|
|
1
1
|
/*
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
2
|
+
* $RCSfile$
|
3
|
+
*
|
4
|
+
* Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
|
5
|
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
6
|
+
*
|
7
|
+
* This code is free software; you can redistribute it and/or modify it
|
8
|
+
* under the terms of the GNU General Public License version 2 only, as
|
9
|
+
* published by the Free Software Foundation. Sun designates this
|
10
|
+
* particular file as subject to the "Classpath" exception as provided
|
11
|
+
* by Sun in the LICENSE file that accompanied this code.
|
12
|
+
*
|
13
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
14
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
* version 2 for more details (a copy is included in the LICENSE file that
|
17
|
+
* accompanied this code).
|
18
|
+
*
|
19
|
+
* You should have received a copy of the GNU General Public License version
|
20
|
+
* 2 along with this work; if not, write to the Free Software Foundation,
|
21
|
+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
22
|
+
*
|
23
|
+
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
24
|
+
* CA 95054 USA or visit www.sun.com if you need additional information or
|
25
|
+
* have any questions.
|
26
|
+
*
|
27
|
+
* $Revision: 127 $
|
28
|
+
* $Date: 2008-02-28 20:18:51 +0000 (Thu, 28 Feb 2008) $
|
29
|
+
* $State$
|
30
30
|
*/
|
31
|
-
|
32
31
|
package toxi.geom;
|
33
32
|
|
34
33
|
import toxi.math.MathUtils;
|
@@ -337,7 +336,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
337
336
|
u[8] = -sinl[1] * utemp + cosl[1] * u[8];
|
338
337
|
|
339
338
|
// update v matrices
|
340
|
-
|
341
339
|
vtemp = v[0];
|
342
340
|
v[0] = cosr[0] * vtemp + sinr[0] * v[1];
|
343
341
|
v[1] = -sinr[0] * vtemp + cosr[0] * v[1];
|
@@ -387,7 +385,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
387
385
|
u[5] = -sinl[0] * utemp + cosl[0] * u[5];
|
388
386
|
|
389
387
|
// update v matrices
|
390
|
-
|
391
388
|
vtemp = v[0];
|
392
389
|
v[0] = cosr[0] * vtemp + sinr[0] * v[1];
|
393
390
|
v[1] = -sinr[0] * vtemp + cosr[0] * v[1];
|
@@ -411,7 +408,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
411
408
|
u[8] = -sinl[0] * utemp + cosl[0] * u[8];
|
412
409
|
|
413
410
|
// update v matrices
|
414
|
-
|
415
411
|
vtemp = v[1];
|
416
412
|
v[1] = cosr[0] * vtemp + sinr[0] * v[2];
|
417
413
|
v[2] = -sinr[0] * vtemp + cosr[0] * v[2];
|
@@ -562,7 +558,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
562
558
|
}
|
563
559
|
|
564
560
|
// u1
|
565
|
-
|
566
561
|
if (m[3] * m[3] < EPS) {
|
567
562
|
u1[0] = 1.0;
|
568
563
|
u1[1] = 0.0;
|
@@ -621,7 +616,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
621
616
|
}
|
622
617
|
|
623
618
|
// u2
|
624
|
-
|
625
619
|
if (m[6] * m[6] < EPS) {
|
626
620
|
} else if (m[0] * m[0] < EPS) {
|
627
621
|
tmp[0] = m[0];
|
@@ -674,7 +668,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
674
668
|
}
|
675
669
|
|
676
670
|
// v1
|
677
|
-
|
678
671
|
if (m[2] * m[2] < EPS) {
|
679
672
|
v1[0] = 1.0;
|
680
673
|
v1[1] = 0.0;
|
@@ -734,7 +727,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
734
727
|
}
|
735
728
|
|
736
729
|
// u3
|
737
|
-
|
738
730
|
if (m[7] * m[7] < EPS) {
|
739
731
|
} else if (m[4] * m[4] < EPS) {
|
740
732
|
tmp[3] = m[3];
|
@@ -839,7 +831,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
839
831
|
* "matrix2" in turn and treats it as the right-hand side of the matrix
|
840
832
|
* equation Ax = LUx = b. The solution vector replaces the original column
|
841
833
|
* of the matrix.
|
842
|
-
*
|
834
|
+
*
|
843
835
|
* If "matrix2" is the identity matrix, the procedure replaces its contents
|
844
836
|
* with the inverse of the matrix from which "matrix1" was originally
|
845
837
|
* derived.
|
@@ -1020,12 +1012,11 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1020
1012
|
}
|
1021
1013
|
|
1022
1014
|
/*
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1015
|
+
* System.out.println("\nscales="+scales[0]+" "+scales[1]+" "+scales[
|
1016
|
+
* 2]); System.out.println("\nrot="+rot[0]+" "+rot[1]+" "+rot[2]);
|
1017
|
+
* System.out.println("rot="+rot[3]+" "+rot[4]+" "+rot[5]);
|
1018
|
+
* System.out.println("rot="+rot[6]+" "+rot[7]+" "+rot[8]);
|
1027
1019
|
*/
|
1028
|
-
|
1029
1020
|
// sort the order of the input matrix
|
1030
1021
|
mag[0] = (m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
|
1031
1022
|
mag[1] = (m[3] * m[3] + m[4] * m[4] + m[5] * m[5]);
|
@@ -1197,25 +1188,16 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1197
1188
|
|
1198
1189
|
/**
|
1199
1190
|
* Constructs and initializes a Matrix3d from the specified nine values.
|
1200
|
-
*
|
1201
|
-
* @param m00
|
1202
|
-
*
|
1203
|
-
* @param
|
1204
|
-
*
|
1205
|
-
* @param
|
1206
|
-
*
|
1207
|
-
* @param
|
1208
|
-
*
|
1209
|
-
* @param
|
1210
|
-
* the [1][1] element
|
1211
|
-
* @param m12
|
1212
|
-
* the [1][2] element
|
1213
|
-
* @param m20
|
1214
|
-
* the [2][0] element
|
1215
|
-
* @param m21
|
1216
|
-
* the [2][1] element
|
1217
|
-
* @param m22
|
1218
|
-
* the [2][2] element
|
1191
|
+
*
|
1192
|
+
* @param m00 the [0][0] element
|
1193
|
+
* @param m01 the [0][1] element
|
1194
|
+
* @param m02 the [0][2] element
|
1195
|
+
* @param m10 the [1][0] element
|
1196
|
+
* @param m11 the [1][1] element
|
1197
|
+
* @param m12 the [1][2] element
|
1198
|
+
* @param m20 the [2][0] element
|
1199
|
+
* @param m21 the [2][1] element
|
1200
|
+
* @param m22 the [2][2] element
|
1219
1201
|
*/
|
1220
1202
|
public Matrix3d(double m00, double m01, double m02, double m10, double m11,
|
1221
1203
|
double m12, double m20, double m21, double m22) {
|
@@ -1236,9 +1218,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1236
1218
|
/**
|
1237
1219
|
* Constructs and initializes a Matrix3d from the specified nine- element
|
1238
1220
|
* array.
|
1239
|
-
*
|
1240
|
-
* @param v
|
1241
|
-
* the array of length 9 containing in order
|
1221
|
+
*
|
1222
|
+
* @param v the array of length 9 containing in order
|
1242
1223
|
*/
|
1243
1224
|
public Matrix3d(double[] v) {
|
1244
1225
|
this.m00 = v[0];
|
@@ -1257,9 +1238,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1257
1238
|
|
1258
1239
|
/**
|
1259
1240
|
* Constructs a new matrix with the same values as the Matrix3d parameter.
|
1260
|
-
*
|
1261
|
-
* @param m1
|
1262
|
-
* the source matrix
|
1241
|
+
*
|
1242
|
+
* @param m1 the source matrix
|
1263
1243
|
*/
|
1264
1244
|
public Matrix3d(Matrix3d m1) {
|
1265
1245
|
this.m00 = m1.m00;
|
@@ -1278,9 +1258,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1278
1258
|
|
1279
1259
|
/**
|
1280
1260
|
* Adds a scalar to each component of this matrix.
|
1281
|
-
*
|
1282
|
-
* @param scalar
|
1283
|
-
* the scalar adder
|
1261
|
+
*
|
1262
|
+
* @param scalar the scalar adder
|
1284
1263
|
*/
|
1285
1264
|
public final void add(double scalar) {
|
1286
1265
|
m00 += scalar;
|
@@ -1300,11 +1279,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1300
1279
|
/**
|
1301
1280
|
* Adds a scalar to each component of the matrix m1 and places the result
|
1302
1281
|
* into this. Matrix m1 is not modified.
|
1303
|
-
*
|
1304
|
-
* @param scalar
|
1305
|
-
*
|
1306
|
-
* @param m1
|
1307
|
-
* the original matrix values
|
1282
|
+
*
|
1283
|
+
* @param scalar the scalar adder
|
1284
|
+
* @param m1 the original matrix values
|
1308
1285
|
*/
|
1309
1286
|
public final void add(double scalar, Matrix3d m1) {
|
1310
1287
|
this.m00 = m1.m00 + scalar;
|
@@ -1322,9 +1299,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1322
1299
|
|
1323
1300
|
/**
|
1324
1301
|
* Sets the value of this matrix to the sum of itself and matrix m1.
|
1325
|
-
*
|
1326
|
-
* @param m1
|
1327
|
-
* the other matrix
|
1302
|
+
*
|
1303
|
+
* @param m1 the other matrix
|
1328
1304
|
*/
|
1329
1305
|
public final void add(Matrix3d m1) {
|
1330
1306
|
this.m00 += m1.m00;
|
@@ -1342,11 +1318,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1342
1318
|
|
1343
1319
|
/**
|
1344
1320
|
* Sets the value of this matrix to the matrix sum of matrices m1 and m2.
|
1345
|
-
*
|
1346
|
-
* @param m1
|
1347
|
-
*
|
1348
|
-
* @param m2
|
1349
|
-
* the second matrix
|
1321
|
+
*
|
1322
|
+
* @param m1 the first matrix
|
1323
|
+
* @param m2 the second matrix
|
1350
1324
|
*/
|
1351
1325
|
public final void add(Matrix3d m1, Matrix3d m2) {
|
1352
1326
|
this.m00 = m1.m00 + m2.m00;
|
@@ -1364,29 +1338,26 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1364
1338
|
|
1365
1339
|
/**
|
1366
1340
|
* Creates a new object of the same class as this object.
|
1367
|
-
*
|
1341
|
+
*
|
1368
1342
|
* @return a clone of this instance.
|
1369
|
-
* @exception OutOfMemoryError
|
1370
|
-
* if there is not enough memory.
|
1343
|
+
* @exception OutOfMemoryError if there is not enough memory.
|
1371
1344
|
* @see java.lang.Cloneable
|
1372
1345
|
* @since vecmath 1.3
|
1373
1346
|
*/
|
1374
|
-
// public Object clone() {
|
1375
|
-
// Matrix3d m1 = null;
|
1376
|
-
// try {
|
1377
|
-
// m1 = (Matrix3d) super.clone();
|
1378
|
-
// } catch (CloneNotSupportedException e) {
|
1379
|
-
// // this shouldn't happen, since we are Cloneable
|
1380
|
-
// throw new InternalError();
|
1381
|
-
// }
|
1382
|
-
|
1383
|
-
|
1384
|
-
//
|
1385
|
-
// }
|
1386
|
-
|
1347
|
+
// public Object clone() {
|
1348
|
+
// Matrix3d m1 = null;
|
1349
|
+
// try {
|
1350
|
+
// m1 = (Matrix3d) super.clone();
|
1351
|
+
// } catch (CloneNotSupportedException e) {
|
1352
|
+
// // this shouldn't happen, since we are Cloneable
|
1353
|
+
// throw new InternalError();
|
1354
|
+
// }
|
1355
|
+
// Also need to create new tmp arrays (no need to actually clone them)
|
1356
|
+
// return m1;
|
1357
|
+
// }
|
1387
1358
|
/**
|
1388
1359
|
* Computes the determinant of this matrix.
|
1389
|
-
*
|
1360
|
+
*
|
1390
1361
|
* @return the determinant of the matrix
|
1391
1362
|
*/
|
1392
1363
|
public final double determinant() {
|
@@ -1403,12 +1374,10 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1403
1374
|
* is less than or equal to the epsilon parameter, otherwise returns false.
|
1404
1375
|
* The L-infinite distance is equal to MAX[i=0,1,2 ; j=0,1,2 ;
|
1405
1376
|
* abs(this.m(i,j) - m1.m(i,j)]
|
1406
|
-
*
|
1407
|
-
* @param m1
|
1408
|
-
*
|
1409
|
-
* @
|
1410
|
-
* the threshold value
|
1411
|
-
* @return
|
1377
|
+
*
|
1378
|
+
* @param m1 the matrix to be compared to this matrix
|
1379
|
+
* @param epsilon the threshold value
|
1380
|
+
* @return
|
1412
1381
|
*/
|
1413
1382
|
public boolean epsilonEquals(Matrix3d m1, double epsilon) {
|
1414
1383
|
double diff;
|
@@ -1460,9 +1429,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1460
1429
|
/**
|
1461
1430
|
* Returns true if all of the data members of Matrix3d m1 are equal to the
|
1462
1431
|
* corresponding data members in this Matrix3d.
|
1463
|
-
*
|
1464
|
-
* @param m1
|
1465
|
-
* the matrix with which the comparison is made
|
1432
|
+
*
|
1433
|
+
* @param m1 the matrix with which the comparison is made
|
1466
1434
|
* @return true or false
|
1467
1435
|
*/
|
1468
1436
|
public boolean equals(Matrix3d m1) {
|
@@ -1481,9 +1449,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1481
1449
|
* Returns true if the Object t1 is of type Matrix3d and all of the data
|
1482
1450
|
* members of t1 are equal to the corresponding data members in this
|
1483
1451
|
* Matrix3d.
|
1484
|
-
*
|
1485
|
-
* @param t1
|
1486
|
-
* the matrix with which the comparison is made
|
1452
|
+
*
|
1453
|
+
* @param t1 the matrix with which the comparison is made
|
1487
1454
|
* @return true or false
|
1488
1455
|
*/
|
1489
1456
|
@Override
|
@@ -1501,11 +1468,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1501
1468
|
/**
|
1502
1469
|
* Retrieves the value at the specified row and column of the specified
|
1503
1470
|
* matrix.
|
1504
|
-
*
|
1505
|
-
* @param row
|
1506
|
-
*
|
1507
|
-
* @param column
|
1508
|
-
* the column number to be retrieved (zero indexed)
|
1471
|
+
*
|
1472
|
+
* @param row the row number to be retrieved (zero indexed)
|
1473
|
+
* @param column the column number to be retrieved (zero indexed)
|
1509
1474
|
* @return the value at the indexed element.
|
1510
1475
|
*/
|
1511
1476
|
public final double get(int row, int column) {
|
@@ -1557,27 +1522,29 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1557
1522
|
/**
|
1558
1523
|
* Copies the matrix values in the specified column into the array
|
1559
1524
|
* parameter.
|
1560
|
-
*
|
1561
|
-
* @param column
|
1562
|
-
*
|
1563
|
-
* @param v
|
1564
|
-
* the array into which the matrix row values will be copied
|
1525
|
+
*
|
1526
|
+
* @param column the matrix column
|
1527
|
+
* @param v the array into which the matrix row values will be copied
|
1565
1528
|
*/
|
1566
1529
|
public final void getColumn(int column, double v[]) {
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1530
|
+
switch (column) {
|
1531
|
+
case 0:
|
1532
|
+
v[0] = m00;
|
1533
|
+
v[1] = m10;
|
1534
|
+
v[2] = m20;
|
1535
|
+
break;
|
1536
|
+
case 1:
|
1537
|
+
v[0] = m01;
|
1538
|
+
v[1] = m11;
|
1539
|
+
v[2] = m21;
|
1540
|
+
break;
|
1541
|
+
case 2:
|
1542
|
+
v[0] = m02;
|
1543
|
+
v[1] = m12;
|
1544
|
+
v[2] = m22;
|
1545
|
+
break;
|
1546
|
+
default:
|
1547
|
+
throw new ArrayIndexOutOfBoundsException();
|
1581
1548
|
}
|
1582
1549
|
|
1583
1550
|
}
|
@@ -1585,80 +1552,86 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1585
1552
|
/**
|
1586
1553
|
* Copies the matrix values in the specified column into the vector
|
1587
1554
|
* parameter.
|
1588
|
-
*
|
1589
|
-
* @param column
|
1590
|
-
*
|
1591
|
-
* @param v
|
1592
|
-
* the vector into which the matrix row values will be copied
|
1555
|
+
*
|
1556
|
+
* @param column the matrix column
|
1557
|
+
* @param v the vector into which the matrix row values will be copied
|
1593
1558
|
*/
|
1594
1559
|
public final void getColumn(int column, Vec3D v) {
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1560
|
+
switch (column) {
|
1561
|
+
case 0:
|
1562
|
+
v.x = (float) m00;
|
1563
|
+
v.y = (float) m10;
|
1564
|
+
v.z = (float) m20;
|
1565
|
+
break;
|
1566
|
+
case 1:
|
1567
|
+
v.x = (float) m01;
|
1568
|
+
v.y = (float) m11;
|
1569
|
+
v.z = (float) m21;
|
1570
|
+
break;
|
1571
|
+
case 2:
|
1572
|
+
v.x = (float) m02;
|
1573
|
+
v.y = (float) m12;
|
1574
|
+
v.z = (float) m22;
|
1575
|
+
break;
|
1576
|
+
default:
|
1577
|
+
throw new ArrayIndexOutOfBoundsException();
|
1609
1578
|
}
|
1610
1579
|
|
1611
1580
|
}
|
1612
1581
|
|
1613
1582
|
/**
|
1614
1583
|
* Copies the matrix values in the specified row into the array parameter.
|
1615
|
-
*
|
1616
|
-
* @param row
|
1617
|
-
*
|
1618
|
-
* @param v
|
1619
|
-
* the array into which the matrix row values will be copied
|
1584
|
+
*
|
1585
|
+
* @param row the matrix row
|
1586
|
+
* @param v the array into which the matrix row values will be copied
|
1620
1587
|
*/
|
1621
1588
|
public final void getRow(int row, double v[]) {
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1589
|
+
switch (row) {
|
1590
|
+
case 0:
|
1591
|
+
v[0] = m00;
|
1592
|
+
v[1] = m01;
|
1593
|
+
v[2] = m02;
|
1594
|
+
break;
|
1595
|
+
case 1:
|
1596
|
+
v[0] = m10;
|
1597
|
+
v[1] = m11;
|
1598
|
+
v[2] = m12;
|
1599
|
+
break;
|
1600
|
+
case 2:
|
1601
|
+
v[0] = m20;
|
1602
|
+
v[1] = m21;
|
1603
|
+
v[2] = m22;
|
1604
|
+
break;
|
1605
|
+
default:
|
1606
|
+
throw new ArrayIndexOutOfBoundsException();
|
1636
1607
|
}
|
1637
1608
|
}
|
1638
1609
|
|
1639
1610
|
/**
|
1640
1611
|
* Copies the matrix values in the specified row into the vector parameter.
|
1641
|
-
*
|
1642
|
-
* @param row
|
1643
|
-
*
|
1644
|
-
* @param v
|
1645
|
-
* the vector into which the matrix row values will be copied
|
1612
|
+
*
|
1613
|
+
* @param row the matrix row
|
1614
|
+
* @param v the vector into which the matrix row values will be copied
|
1646
1615
|
*/
|
1647
1616
|
public final void getRow(int row, Vec3D v) {
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1617
|
+
switch (row) {
|
1618
|
+
case 0:
|
1619
|
+
v.x = (float) m00;
|
1620
|
+
v.y = (float) m01;
|
1621
|
+
v.z = (float) m02;
|
1622
|
+
break;
|
1623
|
+
case 1:
|
1624
|
+
v.x = (float) m10;
|
1625
|
+
v.y = (float) m11;
|
1626
|
+
v.z = (float) m12;
|
1627
|
+
break;
|
1628
|
+
case 2:
|
1629
|
+
v.x = (float) m20;
|
1630
|
+
v.y = (float) m21;
|
1631
|
+
v.z = (float) m22;
|
1632
|
+
break;
|
1633
|
+
default:
|
1634
|
+
throw new ArrayIndexOutOfBoundsException();
|
1662
1635
|
}
|
1663
1636
|
|
1664
1637
|
}
|
@@ -1668,7 +1641,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1668
1641
|
* uniform scale factor. If the matrix has non-uniform scale factors, the
|
1669
1642
|
* largest of the x, y, and z scale factors will be returned. This matrix is
|
1670
1643
|
* not modified.
|
1671
|
-
*
|
1644
|
+
*
|
1672
1645
|
* @return the scale factor of this matrix
|
1673
1646
|
*/
|
1674
1647
|
public final double getScale() {
|
@@ -1703,7 +1676,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1703
1676
|
* Matrix3d.equals returns true) will return the same hash code value. Two
|
1704
1677
|
* objects with different data members may return the same hash value,
|
1705
1678
|
* although this is not likely.
|
1706
|
-
*
|
1679
|
+
*
|
1707
1680
|
* @return the integer hash code value
|
1708
1681
|
*/
|
1709
1682
|
@Override
|
@@ -1731,9 +1704,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1731
1704
|
/**
|
1732
1705
|
* Sets the value of this matrix to the matrix inverse of the passed matrix
|
1733
1706
|
* m1.
|
1734
|
-
*
|
1735
|
-
* @param m1
|
1736
|
-
* the matrix to be inverted
|
1707
|
+
*
|
1708
|
+
* @param m1 the matrix to be inverted
|
1737
1709
|
*/
|
1738
1710
|
public final void invert(Matrix3d m1) {
|
1739
1711
|
invertGeneral(m1);
|
@@ -1743,7 +1715,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1743
1715
|
* General invert routine. Inverts m1 and places the result in "this". Note
|
1744
1716
|
* that this routine handles both the "this" version and the non-"this"
|
1745
1717
|
* version.
|
1746
|
-
*
|
1718
|
+
*
|
1747
1719
|
* Also note that since this routine is slow anyway, we won't worry about
|
1748
1720
|
* allocating a little bit of garbage.
|
1749
1721
|
*/
|
@@ -1755,7 +1727,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1755
1727
|
|
1756
1728
|
// Use LU decomposition and backsubstitution code specifically
|
1757
1729
|
// for floating-point 3x3 matrices.
|
1758
|
-
|
1759
1730
|
// Copy source matrix to t1tmp
|
1760
1731
|
tmp[0] = m1.m00;
|
1761
1732
|
tmp[1] = m1.m01;
|
@@ -1800,9 +1771,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1800
1771
|
|
1801
1772
|
/**
|
1802
1773
|
* Multiplies each element of this matrix by a scalar.
|
1803
|
-
*
|
1804
|
-
* @param scalar
|
1805
|
-
* The scalar multiplier.
|
1774
|
+
*
|
1775
|
+
* @param scalar The scalar multiplier.
|
1806
1776
|
*/
|
1807
1777
|
public final void mul(double scalar) {
|
1808
1778
|
m00 *= scalar;
|
@@ -1822,11 +1792,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1822
1792
|
/**
|
1823
1793
|
* Multiplies each element of matrix m1 by a scalar and places the result
|
1824
1794
|
* into this. Matrix m1 is not modified.
|
1825
|
-
*
|
1826
|
-
* @param scalar
|
1827
|
-
*
|
1828
|
-
* @param m1
|
1829
|
-
* the original matrix
|
1795
|
+
*
|
1796
|
+
* @param scalar the scalar multiplier
|
1797
|
+
* @param m1 the original matrix
|
1830
1798
|
*/
|
1831
1799
|
public final void mul(double scalar, Matrix3d m1) {
|
1832
1800
|
this.m00 = scalar * m1.m00;
|
@@ -1846,9 +1814,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1846
1814
|
/**
|
1847
1815
|
* Sets the value of this matrix to the result of multiplying itself with
|
1848
1816
|
* matrix m1.
|
1849
|
-
*
|
1850
|
-
* @param m1
|
1851
|
-
* the other matrix
|
1817
|
+
*
|
1818
|
+
* @param m1 the other matrix
|
1852
1819
|
*/
|
1853
1820
|
public final void mul(Matrix3d m1) {
|
1854
1821
|
double tm00, tm01, tm02, tm10, tm11, tm12, tm20, tm21, tm22;
|
@@ -1879,11 +1846,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1879
1846
|
/**
|
1880
1847
|
* Sets the value of this matrix to the result of multiplying the two
|
1881
1848
|
* argument matrices together.
|
1882
|
-
*
|
1883
|
-
* @param m1
|
1884
|
-
*
|
1885
|
-
* @param m2
|
1886
|
-
* the second matrix
|
1849
|
+
*
|
1850
|
+
* @param m1 the first matrix
|
1851
|
+
* @param m2 the second matrix
|
1887
1852
|
*/
|
1888
1853
|
public final void mul(Matrix3d m1, Matrix3d m2) {
|
1889
1854
|
if (this != m1 && this != m2) {
|
@@ -1900,7 +1865,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1900
1865
|
this.m22 = m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22;
|
1901
1866
|
} else {
|
1902
1867
|
double tm00, tm01, tm02, tm10, tm11, tm12, tm20, tm21, tm22; // vars for temp
|
1903
|
-
|
1868
|
+
// result matrix
|
1904
1869
|
|
1905
1870
|
tm00 = m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20;
|
1906
1871
|
tm01 = m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21;
|
@@ -1930,9 +1895,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1930
1895
|
* Multiplies this matrix by matrix m1, does an SVD normalization of the
|
1931
1896
|
* result, and places the result back into this matrix this =
|
1932
1897
|
* SVDnorm(this*m1).
|
1933
|
-
*
|
1934
|
-
* @param m1
|
1935
|
-
* the matrix on the right hand side of the multiplication
|
1898
|
+
*
|
1899
|
+
* @param m1 the matrix on the right hand side of the multiplication
|
1936
1900
|
*/
|
1937
1901
|
public final void mulNormalize(Matrix3d m1) {
|
1938
1902
|
|
@@ -1971,11 +1935,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
1971
1935
|
/**
|
1972
1936
|
* Multiplies matrix m1 by matrix m2, does an SVD normalization of the
|
1973
1937
|
* result, and places the result into this matrix this = SVDnorm(m1*m2).
|
1974
|
-
*
|
1975
|
-
* @param m1
|
1976
|
-
*
|
1977
|
-
* @param m2
|
1978
|
-
* the matrix on the right hand side of the multiplication
|
1938
|
+
*
|
1939
|
+
* @param m1 the matrix on the left hand side of the multiplication
|
1940
|
+
* @param m2 the matrix on the right hand side of the multiplication
|
1979
1941
|
*/
|
1980
1942
|
public final void mulNormalize(Matrix3d m1, Matrix3d m2) {
|
1981
1943
|
|
@@ -2014,11 +1976,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2014
1976
|
/**
|
2015
1977
|
* Multiplies the transpose of matrix m1 times the transpose of matrix m2,
|
2016
1978
|
* and places the result into this.
|
2017
|
-
*
|
2018
|
-
* @param m1
|
2019
|
-
*
|
2020
|
-
* @param m2
|
2021
|
-
* the matrix on the right hand side of the multiplication
|
1979
|
+
*
|
1980
|
+
* @param m1 the matrix on the left hand side of the multiplication
|
1981
|
+
* @param m2 the matrix on the right hand side of the multiplication
|
2022
1982
|
*/
|
2023
1983
|
public final void mulTransposeBoth(Matrix3d m1, Matrix3d m2) {
|
2024
1984
|
if (this != m1 && this != m2) {
|
@@ -2035,7 +1995,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2035
1995
|
this.m22 = m1.m02 * m2.m20 + m1.m12 * m2.m21 + m1.m22 * m2.m22;
|
2036
1996
|
} else {
|
2037
1997
|
double tm00, tm01, tm02, tm10, tm11, tm12, tm20, tm21, tm22; // vars for temp
|
2038
|
-
|
1998
|
+
// result matrix
|
2039
1999
|
|
2040
2000
|
tm00 = m1.m00 * m2.m00 + m1.m10 * m2.m01 + m1.m20 * m2.m02;
|
2041
2001
|
tm01 = m1.m00 * m2.m10 + m1.m10 * m2.m11 + m1.m20 * m2.m12;
|
@@ -2065,11 +2025,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2065
2025
|
/**
|
2066
2026
|
* Multiplies the transpose of matrix m1 times matrix m2, and places the
|
2067
2027
|
* result into this.
|
2068
|
-
*
|
2069
|
-
* @param m1
|
2070
|
-
*
|
2071
|
-
* @param m2
|
2072
|
-
* the matrix on the right hand side of the multiplication
|
2028
|
+
*
|
2029
|
+
* @param m1 the matrix on the left hand side of the multiplication
|
2030
|
+
* @param m2 the matrix on the right hand side of the multiplication
|
2073
2031
|
*/
|
2074
2032
|
public final void mulTransposeLeft(Matrix3d m1, Matrix3d m2) {
|
2075
2033
|
if (this != m1 && this != m2) {
|
@@ -2086,7 +2044,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2086
2044
|
this.m22 = m1.m02 * m2.m02 + m1.m12 * m2.m12 + m1.m22 * m2.m22;
|
2087
2045
|
} else {
|
2088
2046
|
double tm00, tm01, tm02, tm10, tm11, tm12, tm20, tm21, tm22; // vars for temp
|
2089
|
-
|
2047
|
+
// result matrix
|
2090
2048
|
|
2091
2049
|
tm00 = m1.m00 * m2.m00 + m1.m10 * m2.m10 + m1.m20 * m2.m20;
|
2092
2050
|
tm01 = m1.m00 * m2.m01 + m1.m10 * m2.m11 + m1.m20 * m2.m21;
|
@@ -2115,11 +2073,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2115
2073
|
/**
|
2116
2074
|
* Multiplies matrix m1 times the transpose of matrix m2, and places the
|
2117
2075
|
* result into this.
|
2118
|
-
*
|
2119
|
-
* @param m1
|
2120
|
-
*
|
2121
|
-
* @param m2
|
2122
|
-
* the matrix on the right hand side of the multiplication
|
2076
|
+
*
|
2077
|
+
* @param m1 the matrix on the left hand side of the multiplication
|
2078
|
+
* @param m2 the matrix on the right hand side of the multiplication
|
2123
2079
|
*/
|
2124
2080
|
public final void mulTransposeRight(Matrix3d m1, Matrix3d m2) {
|
2125
2081
|
if (this != m1 && this != m2) {
|
@@ -2136,7 +2092,7 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2136
2092
|
this.m22 = m1.m20 * m2.m20 + m1.m21 * m2.m21 + m1.m22 * m2.m22;
|
2137
2093
|
} else {
|
2138
2094
|
double tm00, tm01, tm02, tm10, tm11, tm12, tm20, tm21, tm22; // vars for temp
|
2139
|
-
|
2095
|
+
// result matrix
|
2140
2096
|
|
2141
2097
|
tm00 = m1.m00 * m2.m00 + m1.m01 * m2.m01 + m1.m02 * m2.m02;
|
2142
2098
|
tm01 = m1.m00 * m2.m10 + m1.m01 * m2.m11 + m1.m02 * m2.m12;
|
@@ -2183,9 +2139,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2183
2139
|
/**
|
2184
2140
|
* Sets the value of this matrix equal to the negation of of the Matrix3d
|
2185
2141
|
* parameter.
|
2186
|
-
*
|
2187
|
-
* @param m1
|
2188
|
-
* the source matrix
|
2142
|
+
*
|
2143
|
+
* @param m1 the source matrix
|
2189
2144
|
*/
|
2190
2145
|
public final void negate(Matrix3d m1) {
|
2191
2146
|
this.m00 = -m1.m00;
|
@@ -2228,9 +2183,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2228
2183
|
/**
|
2229
2184
|
* Perform singular value decomposition normalization of matrix m1 and place
|
2230
2185
|
* the normalized values into this.
|
2231
|
-
*
|
2232
|
-
* @param m1
|
2233
|
-
* Provides the matrix values to be normalized
|
2186
|
+
*
|
2187
|
+
* @param m1 Provides the matrix values to be normalized
|
2234
2188
|
*/
|
2235
2189
|
public final void normalize(Matrix3d m1) {
|
2236
2190
|
|
@@ -2268,7 +2222,6 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2268
2222
|
/**
|
2269
2223
|
* Perform cross product normalization of this matrix.
|
2270
2224
|
*/
|
2271
|
-
|
2272
2225
|
public final void normalizeCP() {
|
2273
2226
|
double mag = 1.0 / Math.sqrt(m00 * m00 + m10 * m10 + m20 * m20);
|
2274
2227
|
m00 = m00 * mag;
|
@@ -2288,9 +2241,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2288
2241
|
/**
|
2289
2242
|
* Perform cross product normalization of matrix m1 and place the normalized
|
2290
2243
|
* values into this.
|
2291
|
-
*
|
2292
|
-
* @param m1
|
2293
|
-
* Provides the matrix values to be normalized
|
2244
|
+
*
|
2245
|
+
* @param m1 Provides the matrix values to be normalized
|
2294
2246
|
*/
|
2295
2247
|
public final void normalizeCP(Matrix3d m1) {
|
2296
2248
|
double mag = 1.0 / Math.sqrt(m1.m00 * m1.m00 + m1.m10 * m1.m10 + m1.m20
|
@@ -2313,9 +2265,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2313
2265
|
/**
|
2314
2266
|
* Sets the value of this matrix to a counter clockwise rotation about the x
|
2315
2267
|
* axis.
|
2316
|
-
*
|
2317
|
-
* @param angle
|
2318
|
-
* the angle to rotate about the X axis in radians
|
2268
|
+
*
|
2269
|
+
* @param angle the angle to rotate about the X axis in radians
|
2319
2270
|
*/
|
2320
2271
|
public final void rotX(double angle) {
|
2321
2272
|
double sinAngle, cosAngle;
|
@@ -2339,9 +2290,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2339
2290
|
/**
|
2340
2291
|
* Sets the value of this matrix to a counter clockwise rotation about the y
|
2341
2292
|
* axis.
|
2342
|
-
*
|
2343
|
-
* @param angle
|
2344
|
-
* the angle to rotate about the Y axis in radians
|
2293
|
+
*
|
2294
|
+
* @param angle the angle to rotate about the Y axis in radians
|
2345
2295
|
*/
|
2346
2296
|
public final void rotY(double angle) {
|
2347
2297
|
double sinAngle, cosAngle;
|
@@ -2365,9 +2315,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2365
2315
|
/**
|
2366
2316
|
* Sets the value of this matrix to a counter clockwise rotation about the z
|
2367
2317
|
* axis.
|
2368
|
-
*
|
2369
|
-
* @param angle
|
2370
|
-
* the angle to rotate about the Z axis in radians
|
2318
|
+
*
|
2319
|
+
* @param angle the angle to rotate about the Z axis in radians
|
2371
2320
|
*/
|
2372
2321
|
public final void rotZ(double angle) {
|
2373
2322
|
double sinAngle, cosAngle;
|
@@ -2391,9 +2340,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2391
2340
|
/**
|
2392
2341
|
* Sets the value of this matrix to a scale matrix with the passed scale
|
2393
2342
|
* amount.
|
2394
|
-
*
|
2395
|
-
* @param scale
|
2396
|
-
* the scale factor for the matrix
|
2343
|
+
*
|
2344
|
+
* @param scale the scale factor for the matrix
|
2397
2345
|
*/
|
2398
2346
|
public final void set(double scale) {
|
2399
2347
|
this.m00 = scale;
|
@@ -2413,9 +2361,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2413
2361
|
* Sets the values in this Matrix3d equal to the row-major array parameter
|
2414
2362
|
* (ie, the first three elements of the array will be copied into the first
|
2415
2363
|
* row of this matrix, etc.).
|
2416
|
-
*
|
2417
|
-
* @param m
|
2418
|
-
* the double precision array of length 9
|
2364
|
+
*
|
2365
|
+
* @param m the double precision array of length 9
|
2419
2366
|
*/
|
2420
2367
|
public final void set(double[] m) {
|
2421
2368
|
m00 = m[0];
|
@@ -2434,9 +2381,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2434
2381
|
|
2435
2382
|
/**
|
2436
2383
|
* Sets the value of this matrix to the value of the Matrix3d argument.
|
2437
|
-
*
|
2438
|
-
* @param m1
|
2439
|
-
* the source matrix3d
|
2384
|
+
*
|
2385
|
+
* @param m1 the source matrix3d
|
2440
2386
|
*/
|
2441
2387
|
public final void set(Matrix3d m1) {
|
2442
2388
|
this.m00 = m1.m00;
|
@@ -2455,9 +2401,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2455
2401
|
/**
|
2456
2402
|
* Sets the value of this matrix to the matrix conversion of the single
|
2457
2403
|
* precision quaternion argument.
|
2458
|
-
*
|
2459
|
-
* @param q1
|
2460
|
-
* the quaternion to be converted
|
2404
|
+
*
|
2405
|
+
* @param q1 the quaternion to be converted
|
2461
2406
|
*/
|
2462
2407
|
public final void set(Quaternion q1) {
|
2463
2408
|
this.m00 = (1.0 - 2.0 * q1.y * q1.y - 2.0 * q1.z * q1.z);
|
@@ -2475,11 +2420,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2475
2420
|
|
2476
2421
|
/**
|
2477
2422
|
* Sets the specified column of this matrix3d to the three values provided.
|
2478
|
-
*
|
2479
|
-
* @param column
|
2480
|
-
*
|
2481
|
-
* @param v
|
2482
|
-
* the replacement column
|
2423
|
+
*
|
2424
|
+
* @param column the column number to be modified (zero indexed)
|
2425
|
+
* @param v the replacement column
|
2483
2426
|
*/
|
2484
2427
|
public final void setColumn(int column, double v[]) {
|
2485
2428
|
switch (column) {
|
@@ -2508,15 +2451,11 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2508
2451
|
|
2509
2452
|
/**
|
2510
2453
|
* Sets the specified column of this matrix3d to the three values provided.
|
2511
|
-
*
|
2512
|
-
* @param column
|
2513
|
-
*
|
2514
|
-
* @param
|
2515
|
-
*
|
2516
|
-
* @param y
|
2517
|
-
* the second row element
|
2518
|
-
* @param z
|
2519
|
-
* the third row element
|
2454
|
+
*
|
2455
|
+
* @param column the column number to be modified (zero indexed)
|
2456
|
+
* @param x the first row element
|
2457
|
+
* @param y the second row element
|
2458
|
+
* @param z the third row element
|
2520
2459
|
*/
|
2521
2460
|
public final void setColumn(int column, double x, double y, double z) {
|
2522
2461
|
switch (column) {
|
@@ -2545,11 +2484,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2545
2484
|
|
2546
2485
|
/**
|
2547
2486
|
* Sets the specified column of this matrix3d to the vector provided.
|
2548
|
-
*
|
2549
|
-
* @param column
|
2550
|
-
*
|
2551
|
-
* @param v
|
2552
|
-
* the replacement column
|
2487
|
+
*
|
2488
|
+
* @param column the column number to be modified (zero indexed)
|
2489
|
+
* @param v the replacement column
|
2553
2490
|
*/
|
2554
2491
|
public final void setColumn(int column, Vec3D v) {
|
2555
2492
|
switch (column) {
|
@@ -2578,13 +2515,10 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2578
2515
|
|
2579
2516
|
/**
|
2580
2517
|
* Sets the specified element of this matrix3f to the value provided.
|
2581
|
-
*
|
2582
|
-
* @param row
|
2583
|
-
*
|
2584
|
-
* @param
|
2585
|
-
* the column number to be modified (zero indexed)
|
2586
|
-
* @param value
|
2587
|
-
* the new value
|
2518
|
+
*
|
2519
|
+
* @param row the row number to be modified (zero indexed)
|
2520
|
+
* @param column the column number to be modified (zero indexed)
|
2521
|
+
* @param value the new value
|
2588
2522
|
*/
|
2589
2523
|
public final void setElement(int row, int column, double value) {
|
2590
2524
|
switch (row) {
|
@@ -2660,10 +2594,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2660
2594
|
|
2661
2595
|
/**
|
2662
2596
|
* Set the first matrix element in the first row.
|
2663
|
-
*
|
2664
|
-
* @param m00
|
2665
|
-
*
|
2666
|
-
*
|
2597
|
+
*
|
2598
|
+
* @param m00 The m00 to set.
|
2599
|
+
*
|
2667
2600
|
* @since vecmath 1.5
|
2668
2601
|
*/
|
2669
2602
|
public final void setM00(double m00) {
|
@@ -2672,10 +2605,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2672
2605
|
|
2673
2606
|
/**
|
2674
2607
|
* Set the second matrix element in the first row.
|
2675
|
-
*
|
2676
|
-
* @param m01
|
2677
|
-
*
|
2678
|
-
*
|
2608
|
+
*
|
2609
|
+
* @param m01 The m01 to set.
|
2610
|
+
*
|
2679
2611
|
* @since vecmath 1.5
|
2680
2612
|
*/
|
2681
2613
|
public final void setM01(double m01) {
|
@@ -2684,10 +2616,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2684
2616
|
|
2685
2617
|
/**
|
2686
2618
|
* Set the third matrix element in the first row.
|
2687
|
-
*
|
2688
|
-
* @param m02
|
2689
|
-
*
|
2690
|
-
*
|
2619
|
+
*
|
2620
|
+
* @param m02 The m02 to set.
|
2621
|
+
*
|
2691
2622
|
* @since vecmath 1.5
|
2692
2623
|
*/
|
2693
2624
|
public final void setM02(double m02) {
|
@@ -2696,10 +2627,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2696
2627
|
|
2697
2628
|
/**
|
2698
2629
|
* Set first matrix element in the second row.
|
2699
|
-
*
|
2700
|
-
* @param m10
|
2701
|
-
*
|
2702
|
-
*
|
2630
|
+
*
|
2631
|
+
* @param m10 The m10 to set.
|
2632
|
+
*
|
2703
2633
|
* @since vecmath 1.5
|
2704
2634
|
*/
|
2705
2635
|
public final void setM10(double m10) {
|
@@ -2708,10 +2638,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2708
2638
|
|
2709
2639
|
/**
|
2710
2640
|
* Set the second matrix element in the second row.
|
2711
|
-
*
|
2712
|
-
* @param m11
|
2713
|
-
*
|
2714
|
-
*
|
2641
|
+
*
|
2642
|
+
* @param m11 The m11 to set.
|
2643
|
+
*
|
2715
2644
|
* @since vecmath 1.5
|
2716
2645
|
*/
|
2717
2646
|
public final void setM11(double m11) {
|
@@ -2720,10 +2649,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2720
2649
|
|
2721
2650
|
/**
|
2722
2651
|
* Set the third matrix element in the second row.
|
2723
|
-
*
|
2724
|
-
* @param m12
|
2725
|
-
*
|
2726
|
-
*
|
2652
|
+
*
|
2653
|
+
* @param m12 The m12 to set.
|
2654
|
+
*
|
2727
2655
|
* @since vecmath 1.5
|
2728
2656
|
*/
|
2729
2657
|
public final void setM12(double m12) {
|
@@ -2732,10 +2660,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2732
2660
|
|
2733
2661
|
/**
|
2734
2662
|
* Set the first matrix element in the third row.
|
2735
|
-
*
|
2736
|
-
* @param m20
|
2737
|
-
*
|
2738
|
-
*
|
2663
|
+
*
|
2664
|
+
* @param m20 The m20 to set.
|
2665
|
+
*
|
2739
2666
|
* @since vecmath 1.5
|
2740
2667
|
*/
|
2741
2668
|
public final void setM20(double m20) {
|
@@ -2744,10 +2671,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2744
2671
|
|
2745
2672
|
/**
|
2746
2673
|
* Set the second matrix element in the third row.
|
2747
|
-
*
|
2748
|
-
* @param m21
|
2749
|
-
*
|
2750
|
-
*
|
2674
|
+
*
|
2675
|
+
* @param m21 The m21 to set.
|
2676
|
+
*
|
2751
2677
|
* @since vecmath 1.5
|
2752
2678
|
*/
|
2753
2679
|
public final void setM21(double m21) {
|
@@ -2756,10 +2682,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2756
2682
|
|
2757
2683
|
/**
|
2758
2684
|
* Set the third matrix element in the third row.
|
2759
|
-
*
|
2760
|
-
* @param m22
|
2761
|
-
*
|
2762
|
-
*
|
2685
|
+
*
|
2686
|
+
* @param m22 The m22 to set.
|
2687
|
+
*
|
2763
2688
|
* @since vecmath 1.5
|
2764
2689
|
*/
|
2765
2690
|
public final void setM22(double m22) {
|
@@ -2768,11 +2693,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2768
2693
|
|
2769
2694
|
/**
|
2770
2695
|
* Sets the specified row of this matrix3d to the three values provided.
|
2771
|
-
*
|
2772
|
-
* @param row
|
2773
|
-
*
|
2774
|
-
* @param v
|
2775
|
-
* the replacement row
|
2696
|
+
*
|
2697
|
+
* @param row the row number to be modified (zero indexed)
|
2698
|
+
* @param v the replacement row
|
2776
2699
|
*/
|
2777
2700
|
public final void setRow(int row, double v[]) {
|
2778
2701
|
switch (row) {
|
@@ -2801,15 +2724,11 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2801
2724
|
|
2802
2725
|
/**
|
2803
2726
|
* Sets the specified row of this matrix3d to the 4 values provided.
|
2804
|
-
*
|
2805
|
-
* @param row
|
2806
|
-
*
|
2807
|
-
* @param
|
2808
|
-
*
|
2809
|
-
* @param y
|
2810
|
-
* the second column element
|
2811
|
-
* @param z
|
2812
|
-
* the third column element
|
2727
|
+
*
|
2728
|
+
* @param row the row number to be modified (zero indexed)
|
2729
|
+
* @param x the first column element
|
2730
|
+
* @param y the second column element
|
2731
|
+
* @param z the third column element
|
2813
2732
|
*/
|
2814
2733
|
public final void setRow(int row, double x, double y, double z) {
|
2815
2734
|
switch (row) {
|
@@ -2838,11 +2757,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2838
2757
|
|
2839
2758
|
/**
|
2840
2759
|
* Sets the specified row of this matrix3d to the Vector provided.
|
2841
|
-
*
|
2842
|
-
* @param row
|
2843
|
-
*
|
2844
|
-
* @param v
|
2845
|
-
* the replacement row
|
2760
|
+
*
|
2761
|
+
* @param row the row number to be modified (zero indexed)
|
2762
|
+
* @param v the replacement row
|
2846
2763
|
*/
|
2847
2764
|
public final void setRow(int row, Vec3D v) {
|
2848
2765
|
switch (row) {
|
@@ -2872,9 +2789,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2872
2789
|
/**
|
2873
2790
|
* Sets the scale component of the current matrix by factoring out the
|
2874
2791
|
* current scale (by doing an SVD) and multiplying by the new scale.
|
2875
|
-
*
|
2876
|
-
* @param scale
|
2877
|
-
* the new scale amount
|
2792
|
+
*
|
2793
|
+
* @param scale the new scale amount
|
2878
2794
|
*/
|
2879
2795
|
public final void setScale(double scale) {
|
2880
2796
|
|
@@ -2917,9 +2833,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2917
2833
|
/**
|
2918
2834
|
* Sets the value of this matrix to the matrix difference of itself and
|
2919
2835
|
* matrix m1 (this = this - m1).
|
2920
|
-
*
|
2921
|
-
* @param m1
|
2922
|
-
* the other matrix
|
2836
|
+
*
|
2837
|
+
* @param m1 the other matrix
|
2923
2838
|
*/
|
2924
2839
|
public final void sub(Matrix3d m1) {
|
2925
2840
|
this.m00 -= m1.m00;
|
@@ -2938,11 +2853,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2938
2853
|
/**
|
2939
2854
|
* Sets the value of this matrix to the matrix difference of matrices m1 and
|
2940
2855
|
* m2.
|
2941
|
-
*
|
2942
|
-
* @param m1
|
2943
|
-
*
|
2944
|
-
* @param m2
|
2945
|
-
* the second matrix
|
2856
|
+
*
|
2857
|
+
* @param m1 the first matrix
|
2858
|
+
* @param m2 the second matrix
|
2946
2859
|
*/
|
2947
2860
|
public final void sub(Matrix3d m1, Matrix3d m2) {
|
2948
2861
|
this.m00 = m1.m00 - m2.m00;
|
@@ -2960,22 +2873,24 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2960
2873
|
|
2961
2874
|
/**
|
2962
2875
|
* Returns a string that contains the values of this Matrix3d.
|
2963
|
-
*
|
2876
|
+
*
|
2964
2877
|
* @return the String representation
|
2965
2878
|
*/
|
2966
2879
|
@Override
|
2967
2880
|
public String toString() {
|
2968
|
-
return
|
2969
|
-
|
2970
|
-
|
2881
|
+
return String.join("\n",
|
2882
|
+
String.format("%f, %f, %f", this.m00, this.m01, this.m02),
|
2883
|
+
String.format("%f, %f, %f", this.m10, this.m11, this.m12),
|
2884
|
+
String.format("%f, %f, %f", this.m20, this.m21, this.m22),
|
2885
|
+
""
|
2886
|
+
);
|
2971
2887
|
}
|
2972
2888
|
|
2973
2889
|
/**
|
2974
2890
|
* Multiply this matrix by the tuple t and place the result back into the
|
2975
2891
|
* tuple (t = this*t).
|
2976
|
-
*
|
2977
|
-
* @param t
|
2978
|
-
* the tuple to be multiplied by this matrix and then replaced
|
2892
|
+
*
|
2893
|
+
* @param t the tuple to be multiplied by this matrix and then replaced
|
2979
2894
|
*/
|
2980
2895
|
public final void transform(Vec3D t) {
|
2981
2896
|
float x, y, z;
|
@@ -2988,11 +2903,9 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
2988
2903
|
/**
|
2989
2904
|
* Multiply this matrix by the tuple t and and place the result into the
|
2990
2905
|
* tuple "result" (result = this*t).
|
2991
|
-
*
|
2992
|
-
* @param t
|
2993
|
-
*
|
2994
|
-
* @param result
|
2995
|
-
* the tuple into which the product is placed
|
2906
|
+
*
|
2907
|
+
* @param t the tuple to be multiplied by this matrix
|
2908
|
+
* @param result the tuple into which the product is placed
|
2996
2909
|
*/
|
2997
2910
|
public final void transform(Vec3D t, Vec3D result) {
|
2998
2911
|
float x, y, z;
|
@@ -3024,9 +2937,8 @@ public class Matrix3d implements java.io.Serializable, Cloneable {
|
|
3024
2937
|
|
3025
2938
|
/**
|
3026
2939
|
* Sets the value of this matrix to the transpose of the argument matrix.
|
3027
|
-
*
|
3028
|
-
* @param m1
|
3029
|
-
* the matrix to be transposed
|
2940
|
+
*
|
2941
|
+
* @param m1 the matrix to be transposed
|
3030
2942
|
*/
|
3031
2943
|
public final void transpose(Matrix3d m1) {
|
3032
2944
|
if (this != m1) {
|