216 T
trace = this->data[0][0] + this->data[1][1] + this->data[2][2];
223 q.SetX((this->data[2][1] - this->data[1][2]) *
root);
224 q.SetY((this->data[0][2] - this->data[2][0]) *
root);
225 q.SetZ((this->data[1][0] - this->data[0][1]) *
root);
229 static unsigned int s_iNext[3] = {1, 2, 0};
231 if (this->data[1][1] > this->data[0][0])
233 if (this->data[2][2] > this->data[
i][
i])
238 root = sqrt(this->data[
i][
i] - this->data[
j][
j] -
239 this->data[k][k] + 1.0);
244 b = (this->data[
j][
i] + this->data[
i][
j]) *
root;
245 c = (this->data[k][
i] + this->data[
i][k]) *
root;
250 case 0: q.SetX(a);
break;
251 case 1: q.SetY(a);
break;
252 case 2: q.SetZ(a);
break;
257 case 0: q.SetX(b);
break;
258 case 1: q.SetY(b);
break;
259 case 2: q.SetZ(b);
break;
264 case 0: q.SetX(
c);
break;
265 case 1: q.SetY(
c);
break;
266 case 2: q.SetZ(
c);
break;
269 q.SetW((this->data[k][
j] - this->data[
j][k]) *
root);
395 v0 = this->data[2][0]*this->data[3][1]
396 - this->data[2][1]*this->data[3][0];
397 v1 = this->data[2][0]*this->data[3][2]
398 - this->data[2][2]*this->data[3][0];
399 v2 = this->data[2][0]*this->data[3][3]
400 - this->data[2][3]*this->data[3][0];
401 v3 = this->data[2][1]*this->data[3][2]
402 - this->data[2][2]*this->data[3][1];
403 v4 = this->data[2][1]*this->data[3][3]
404 - this->data[2][3]*this->data[3][1];
405 v5 = this->data[2][2]*this->data[3][3]
406 - this->data[2][3]*this->data[3][2];
408 t00 =
v5*this->data[1][1] -
v4*this->data[1][2] +
v3*this->data[1][3];
409 t10 = -
v5*this->data[1][0] +
v2*this->data[1][2] -
v1*this->data[1][3];
410 t20 =
v4*this->data[1][0] -
v2*this->data[1][1] +
v0*this->data[1][3];
411 t30 = -
v3*this->data[1][0] +
v1*this->data[1][1] -
v0*this->data[1][2];
413 return t00 * this->data[0][0]
414 +
t10 * this->data[0][1]
415 +
t20 * this->data[0][2]
416 +
t30 * this->data[0][3];
427 v0 = this->data[2][0]*this->data[3][1] -
428 this->data[2][1]*this->data[3][0];
429 v1 = this->data[2][0]*this->data[3][2] -
430 this->data[2][2]*this->data[3][0];
431 v2 = this->data[2][0]*this->data[3][3] -
432 this->data[2][3]*this->data[3][0];
433 v3 = this->data[2][1]*this->data[3][2] -
434 this->data[2][2]*this->data[3][1];
435 v4 = this->data[2][1]*this->data[3][3] -
436 this->data[2][3]*this->data[3][1];
437 v5 = this->data[2][2]*this->data[3][3] -
438 this->data[2][3]*this->data[3][2];
440 t00 = +(
v5*this->data[1][1] -
441 v4*this->data[1][2] +
v3*this->data[1][3]);
442 t10 = -(
v5*this->data[1][0] -
443 v2*this->data[1][2] +
v1*this->data[1][3]);
444 t20 = +(
v4*this->data[1][0] -
445 v2*this->data[1][1] +
v0*this->data[1][3]);
446 t30 = -(
v3*this->data[1][0] -
447 v1*this->data[1][1] +
v0*this->data[1][2]);
449 T
invDet = 1 / (
t00 * this->data[0][0] +
t10 * this->data[0][1] +
450 t20 * this->data[0][2] +
t30 * this->data[0][3]);
457 r(0, 1) = -(
v5*this->data[0][1] -
458 v4*this->data[0][2] +
v3*this->data[0][3]) *
invDet;
459 r(1, 1) = +(
v5*this->data[0][0] -
460 v2*this->data[0][2] +
v1*this->data[0][3]) *
invDet;
461 r(2, 1) = -(
v4*this->data[0][0] -
462 v2*this->data[0][1] +
v0*this->data[0][3]) *
invDet;
463 r(3, 1) = +(
v3*this->data[0][0] -
464 v1*this->data[0][1] +
v0*this->data[0][2]) *
invDet;
466 v0 = this->data[1][0]*this->data[3][1] -
467 this->data[1][1]*this->data[3][0];
468 v1 = this->data[1][0]*this->data[3][2] -
469 this->data[1][2]*this->data[3][0];
470 v2 = this->data[1][0]*this->data[3][3] -
471 this->data[1][3]*this->data[3][0];
472 v3 = this->data[1][1]*this->data[3][2] -
473 this->data[1][2]*this->data[3][1];
474 v4 = this->data[1][1]*this->data[3][3] -
475 this->data[1][3]*this->data[3][1];
476 v5 = this->data[1][2]*this->data[3][3] -
477 this->data[1][3]*this->data[3][2];
479 r(0, 2) = +(
v5*this->data[0][1] -
480 v4*this->data[0][2] +
v3*this->data[0][3]) *
invDet;
481 r(1, 2) = -(
v5*this->data[0][0] -
482 v2*this->data[0][2] +
v1*this->data[0][3]) *
invDet;
483 r(2, 2) = +(
v4*this->data[0][0] -
484 v2*this->data[0][1] +
v0*this->data[0][3]) *
invDet;
485 r(3, 2) = -(
v3*this->data[0][0] -
486 v1*this->data[0][1] +
v0*this->data[0][2]) *
invDet;
488 v0 = this->data[2][1]*this->data[1][0] -
489 this->data[2][0]*this->data[1][1];
490 v1 = this->data[2][2]*this->data[1][0] -
491 this->data[2][0]*this->data[1][2];
492 v2 = this->data[2][3]*this->data[1][0] -
493 this->data[2][0]*this->data[1][3];
494 v3 = this->data[2][2]*this->data[1][1] -
495 this->data[2][1]*this->data[1][2];
496 v4 = this->data[2][3]*this->data[1][1] -
497 this->data[2][1]*this->data[1][3];
498 v5 = this->data[2][3]*this->data[1][2] -
499 this->data[2][2]*this->data[1][3];
501 r(0, 3) = -(
v5*this->data[0][1] -
502 v4*this->data[0][2] +
v3*this->data[0][3]) *
invDet;
503 r(1, 3) = +(
v5*this->data[0][0] -
504 v2*this->data[0][2] +
v1*this->data[0][3]) *
invDet;
505 r(2, 3) = -(
v4*this->data[0][0] -
506 v2*this->data[0][1] +
v0*this->data[0][3]) *
invDet;
507 r(3, 3) = +(
v3*this->data[0][0] -
508 v1*this->data[0][1] +
v0*this->data[0][2]) *
invDet;
516 std::swap(this->data[0][1], this->data[1][0]);
517 std::swap(this->data[0][2], this->data[2][0]);
518 std::swap(this->data[0][3], this->data[3][0]);
519 std::swap(this->data[1][2], this->data[2][1]);
520 std::swap(this->data[1][3], this->data[3][1]);
521 std::swap(this->data[2][3], this->data[3][2]);
529 this->data[0][0], this->data[1][0], this->data[2][0], this->data[3][0],
530 this->data[0][1], this->data[1][1], this->data[2][1], this->data[3][1],
531 this->data[0][2], this->data[1][2], this->data[2][2], this->data[3][2],
532 this->data[0][3], this->data[1][3], this->data[2][3], this->data[3][3]);
763 _in.setf(std::ios_base::skipws);
765 _in >> d[0] >> d[1] >> d[2] >> d[3]
766 >> d[4] >> d[5] >> d[6] >> d[7]
767 >> d[8] >> d[9] >> d[10] >> d[11]
768 >> d[12] >> d[13] >> d[14] >> d[15];
772 _m.
Set(d[0], d[1], d[2], d[3],
773 d[4], d[5], d[6], d[7],
774 d[8], d[9], d[10], d[11],
775 d[12], d[13], d[14], d[15]);