| .. | .. |
|---|
| 306 | 306 | |
|---|
| 307 | 307 | } |
|---|
| 308 | 308 | |
|---|
| 309 | + GrafreeD.Assert(Math.abs(src[0][3]) <= 1E-15); |
|---|
| 310 | + GrafreeD.Assert(Math.abs(src[1][3]) <= 1E-15); |
|---|
| 311 | + GrafreeD.Assert(Math.abs(src[2][3]) <= 1E-15); |
|---|
| 312 | + GrafreeD.Assert(Math.abs(src[3][3] - 1) <= 1E-15); |
|---|
| 313 | + GrafreeD.Assert(Math.abs(dst[0][3]) <= 1E-15); |
|---|
| 314 | + GrafreeD.Assert(Math.abs(dst[1][3]) <= 1E-15); |
|---|
| 315 | + GrafreeD.Assert(Math.abs(dst[2][3]) <= 1E-15); |
|---|
| 316 | + GrafreeD.Assert(Math.abs(dst[3][3] - 1) <= 1E-15); |
|---|
| 309 | 317 | } |
|---|
| 310 | 318 | |
|---|
| 311 | 319 | static double toRadians(double degrees) |
|---|
| .. | .. |
|---|
| 319 | 327 | //left = right; |
|---|
| 320 | 328 | //right = tmp; |
|---|
| 321 | 329 | |
|---|
| 322 | | - for (int i = 0; i < 4; i++) |
|---|
| 330 | + for (int j = 0; j < 4; j++) |
|---|
| 323 | 331 | { |
|---|
| 324 | | - double[] lefti = left[i]; |
|---|
| 325 | | - double[] concati = concatTemp[i]; |
|---|
| 326 | | - for (int j = 0; j < 4; j++) |
|---|
| 332 | + double[] rightj = right[j]; |
|---|
| 333 | + double[] concat = concatTemp[j]; |
|---|
| 334 | + for (int i = 0; i < 4; i++) |
|---|
| 327 | 335 | { |
|---|
| 328 | | - concati[j] = 0; |
|---|
| 336 | + concat[i] = 0; |
|---|
| 329 | 337 | for (int k = 0; k < 4; k++) |
|---|
| 330 | 338 | { |
|---|
| 331 | | - concati[j] += lefti[k] * right[k][j]; |
|---|
| 339 | + concat[i] += left[k][i] * rightj[k]; |
|---|
| 332 | 340 | } |
|---|
| 333 | 341 | } |
|---|
| 334 | 342 | } |
|---|
| .. | .. |
|---|
| 345 | 353 | //xlateTemp[0][3] = dx; |
|---|
| 346 | 354 | //xlateTemp[1][3] = dy; |
|---|
| 347 | 355 | //xlateTemp[2][3] = dz; |
|---|
| 348 | | - matConcat(mat, xlateTemp, mat); |
|---|
| 356 | + matConcat(xlateTemp, mat, mat); |
|---|
| 349 | 357 | } |
|---|
| 350 | 358 | |
|---|
| 351 | 359 | static void matHomogene(double mat[][], double dx, double dy, double dz) |
|---|
| .. | .. |
|---|
| 357 | 365 | //xlateTemp[0][3] = dx; |
|---|
| 358 | 366 | //xlateTemp[1][3] = dy; |
|---|
| 359 | 367 | //xlateTemp[2][3] = dz; |
|---|
| 360 | | - matConcat(mat, xlateTemp, mat); |
|---|
| 368 | + matConcat(xlateTemp, mat, mat); |
|---|
| 361 | 369 | } |
|---|
| 362 | 370 | |
|---|
| 363 | 371 | static void matTranslateInv(double mat[][], double dx, double dy, double dz) |
|---|
| .. | .. |
|---|
| 369 | 377 | //xlateTemp[0][3] = dx; |
|---|
| 370 | 378 | //xlateTemp[1][3] = dy; |
|---|
| 371 | 379 | //xlateTemp[2][3] = dz; |
|---|
| 372 | | - matConcat(xlateTemp, mat, mat); |
|---|
| 380 | + matConcat(mat, xlateTemp, mat); |
|---|
| 373 | 381 | } |
|---|
| 374 | 382 | |
|---|
| 375 | 383 | static void matScale(double mat[][], double sx, double sy, double sz) |
|---|
| .. | .. |
|---|
| 378 | 386 | xlateTemp[0][0] = sx; |
|---|
| 379 | 387 | xlateTemp[1][1] = sy; |
|---|
| 380 | 388 | xlateTemp[2][2] = sz; |
|---|
| 381 | | - matConcat(mat, xlateTemp, mat); |
|---|
| 389 | + matConcat(xlateTemp, mat, mat); |
|---|
| 390 | + //matConcat(mat, xlateTemp, mat); |
|---|
| 382 | 391 | } |
|---|
| 383 | 392 | |
|---|
| 384 | 393 | static void matXRotate(double mat[][], double radians) |
|---|
| .. | .. |
|---|
| 387 | 396 | rotTemp[1][1] = rotTemp[2][2] = (double) Math.cos(radians); |
|---|
| 388 | 397 | rotTemp[2][1] = -(rotTemp[1][2] = (double) Math.sin(radians)); |
|---|
| 389 | 398 | // if (CameraPane.LOCALTRANSFORM) |
|---|
| 390 | | - // matConcat(rotTemp, mat, mat); |
|---|
| 399 | + matConcat(rotTemp, mat, mat); |
|---|
| 391 | 400 | // else |
|---|
| 392 | | - matConcat(mat, rotTemp, mat); |
|---|
| 401 | + // matConcat(mat, rotTemp, mat); |
|---|
| 393 | 402 | } |
|---|
| 394 | 403 | |
|---|
| 395 | 404 | static void matYRotate(double mat[][], double radians) |
|---|
| .. | .. |
|---|
| 398 | 407 | rotTemp[0][0] = rotTemp[2][2] = (double) Math.cos(-radians); |
|---|
| 399 | 408 | rotTemp[2][0] = -(rotTemp[0][2] = (double) Math.sin(-radians)); |
|---|
| 400 | 409 | // if (CameraPane.LOCALTRANSFORM) |
|---|
| 401 | | - // matConcat(rotTemp, mat, mat); |
|---|
| 410 | + matConcat(rotTemp, mat, mat); |
|---|
| 402 | 411 | // else |
|---|
| 403 | | - matConcat(mat, rotTemp, mat); |
|---|
| 412 | + // matConcat(mat, rotTemp, mat); |
|---|
| 404 | 413 | } |
|---|
| 405 | 414 | |
|---|
| 406 | 415 | static void matZRotate(double mat[][], double radians) |
|---|
| .. | .. |
|---|
| 409 | 418 | rotTemp[0][0] = rotTemp[1][1] = (double) Math.cos(radians); |
|---|
| 410 | 419 | rotTemp[1][0] = -(rotTemp[0][1] = (double) Math.sin(radians)); |
|---|
| 411 | 420 | // if (CameraPane.LOCALTRANSFORM) |
|---|
| 412 | | - // matConcat(rotTemp, mat, mat); |
|---|
| 421 | + matConcat(rotTemp, mat, mat); |
|---|
| 413 | 422 | // else |
|---|
| 414 | | - matConcat(mat, rotTemp, mat); |
|---|
| 423 | + // matConcat(mat, rotTemp, mat); |
|---|
| 415 | 424 | } |
|---|
| 416 | 425 | |
|---|
| 417 | 426 | // Project A onto B |
|---|