Normand Briere
2019-05-05 623dc0fa8cbd9473830a1786f6d49fa808a09439
LA.java
....@@ -160,6 +160,7 @@
160160
161161 static cVector xformDir(cVector v, double mat[][])
162162 {
163
+ new Exception().printStackTrace();
163164 System.exit(0);
164165 cVector temp = new cVector();
165166 xformDir(v, mat, temp);
....@@ -306,6 +307,14 @@
306307
307308 }
308309
310
+ Grafreed.Assert(Math.abs(src[0][3]) <= 1E-15);
311
+ Grafreed.Assert(Math.abs(src[1][3]) <= 1E-15);
312
+ Grafreed.Assert(Math.abs(src[2][3]) <= 1E-15);
313
+ Grafreed.Assert(Math.abs(src[3][3] - 1) <= 1E-15);
314
+ Grafreed.Assert(Math.abs(dst[0][3]) <= 1E-15);
315
+ Grafreed.Assert(Math.abs(dst[1][3]) <= 1E-15);
316
+ Grafreed.Assert(Math.abs(dst[2][3]) <= 1E-15);
317
+ Grafreed.Assert(Math.abs(dst[3][3] - 1) <= 1E-15);
309318 }
310319
311320 static double toRadians(double degrees)
....@@ -321,14 +330,14 @@
321330
322331 for (int j = 0; j < 4; j++)
323332 {
324
- double[] leftj = left[j];
333
+ double[] rightj = right[j];
325334 double[] concat = concatTemp[j];
326335 for (int i = 0; i < 4; i++)
327336 {
328337 concat[i] = 0;
329338 for (int k = 0; k < 4; k++)
330339 {
331
- concat[i] += leftj[k] * right[k][i];
340
+ concat[i] += left[k][i] * rightj[k];
332341 }
333342 }
334343 }
....@@ -345,7 +354,7 @@
345354 //xlateTemp[0][3] = dx;
346355 //xlateTemp[1][3] = dy;
347356 //xlateTemp[2][3] = dz;
348
- matConcat(mat, xlateTemp, mat);
357
+ matConcat(xlateTemp, mat, mat);
349358 }
350359
351360 static void matHomogene(double mat[][], double dx, double dy, double dz)
....@@ -357,7 +366,7 @@
357366 //xlateTemp[0][3] = dx;
358367 //xlateTemp[1][3] = dy;
359368 //xlateTemp[2][3] = dz;
360
- matConcat(mat, xlateTemp, mat);
369
+ matConcat(xlateTemp, mat, mat);
361370 }
362371
363372 static void matTranslateInv(double mat[][], double dx, double dy, double dz)
....@@ -369,7 +378,7 @@
369378 //xlateTemp[0][3] = dx;
370379 //xlateTemp[1][3] = dy;
371380 //xlateTemp[2][3] = dz;
372
- matConcat(xlateTemp, mat, mat);
381
+ matConcat(mat, xlateTemp, mat);
373382 }
374383
375384 static void matScale(double mat[][], double sx, double sy, double sz)
....@@ -378,7 +387,8 @@
378387 xlateTemp[0][0] = sx;
379388 xlateTemp[1][1] = sy;
380389 xlateTemp[2][2] = sz;
381
- matConcat(mat, xlateTemp, mat);
390
+ matConcat(xlateTemp, mat, mat);
391
+ //matConcat(mat, xlateTemp, mat);
382392 }
383393
384394 static void matXRotate(double mat[][], double radians)
....@@ -387,9 +397,9 @@
387397 rotTemp[1][1] = rotTemp[2][2] = (double) Math.cos(radians);
388398 rotTemp[2][1] = -(rotTemp[1][2] = (double) Math.sin(radians));
389399 // if (CameraPane.LOCALTRANSFORM)
390
- // matConcat(rotTemp, mat, mat);
400
+ matConcat(rotTemp, mat, mat);
391401 // else
392
- matConcat(mat, rotTemp, mat);
402
+ // matConcat(mat, rotTemp, mat);
393403 }
394404
395405 static void matYRotate(double mat[][], double radians)
....@@ -398,9 +408,9 @@
398408 rotTemp[0][0] = rotTemp[2][2] = (double) Math.cos(-radians);
399409 rotTemp[2][0] = -(rotTemp[0][2] = (double) Math.sin(-radians));
400410 // if (CameraPane.LOCALTRANSFORM)
401
- // matConcat(rotTemp, mat, mat);
411
+ matConcat(rotTemp, mat, mat);
402412 // else
403
- matConcat(mat, rotTemp, mat);
413
+ // matConcat(mat, rotTemp, mat);
404414 }
405415
406416 static void matZRotate(double mat[][], double radians)
....@@ -409,9 +419,9 @@
409419 rotTemp[0][0] = rotTemp[1][1] = (double) Math.cos(radians);
410420 rotTemp[1][0] = -(rotTemp[0][1] = (double) Math.sin(radians));
411421 // if (CameraPane.LOCALTRANSFORM)
412
- // matConcat(rotTemp, mat, mat);
422
+ matConcat(rotTemp, mat, mat);
413423 // else
414
- matConcat(mat, rotTemp, mat);
424
+ // matConcat(mat, rotTemp, mat);
415425 }
416426
417427 // Project A onto B
....@@ -614,6 +624,7 @@
614624 private static int indxr[] = new int[4];
615625 private static int indxc[] = new int[4];
616626
627
+ static double[][] Identity = new double[4][4];
617628
618629 static int SIZE = 0; // 65536*64;
619630
....@@ -629,6 +640,8 @@
629640 costable[i] = Math.cos(PI2 * i/SIZE);
630641 sintable[i] = Math.sin(PI2 * i*i/SIZE/SIZE);
631642 }
643
+
644
+ LA.matIdentity(Identity);
632645 }
633646
634647 static double cos(double x0)