1 Clazz.declarePackage ("javajs.util");
\r
2 Clazz.load (["javajs.util.M34"], "javajs.util.M4", ["javajs.util.T3"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
11 Clazz.instantialize (this, arguments);
\r
12 }, javajs.util, "M4", javajs.util.M34);
\r
13 c$.newA16 = Clazz.defineMethod (c$, "newA16",
\r
15 var m = new javajs.util.M4 ();
\r
34 c$.newM4 = Clazz.defineMethod (c$, "newM4",
\r
36 var m = new javajs.util.M4 ();
\r
49 }, "javajs.util.M4");
\r
50 c$.newMV = Clazz.defineMethod (c$, "newMV",
\r
52 var m = new javajs.util.M4 ();
\r
55 }, "javajs.util.M3,javajs.util.T3");
\r
56 Clazz.defineMethod (c$, "setZero",
\r
59 this.m03 = this.m13 = this.m23 = this.m30 = this.m31 = this.m32 = this.m33 = 0.0;
\r
61 Clazz.defineMethod (c$, "setIdentity",
\r
64 this.m00 = this.m11 = this.m22 = this.m33 = 1.0;
\r
66 Clazz.defineMethod (c$, "setM4",
\r
77 }, "javajs.util.M4");
\r
78 Clazz.defineMethod (c$, "setMV",
\r
81 this.setTranslation (t);
\r
83 }, "javajs.util.M3,javajs.util.T3");
\r
84 Clazz.defineMethod (c$, "setToM3",
\r
87 this.m03 = this.m13 = this.m23 = this.m30 = this.m31 = this.m32 = 0.0;
\r
89 }, "javajs.util.M34");
\r
90 Clazz.defineMethod (c$, "setToAA",
\r
92 this.setIdentity ();
\r
94 }, "javajs.util.A4");
\r
95 Clazz.defineMethod (c$, "setA",
\r
114 Clazz.defineMethod (c$, "setTranslation",
\r
116 this.m03 = trans.x;
\r
117 this.m13 = trans.y;
\r
118 this.m23 = trans.z;
\r
119 }, "javajs.util.T3");
\r
120 Clazz.defineMethod (c$, "setElement",
\r
121 function (row, col, v) {
\r
122 if (row < 3 && col < 3) {
\r
123 this.set33 (row, col, v);
\r
125 }if (row > 3 || col > 3) this.err ();
\r
152 Clazz.defineMethod (c$, "getElement",
\r
153 function (row, col) {
\r
154 if (row < 3 && col < 3) return this.get33 (row, col);
\r
155 if (row > 3 || col > 3) {
\r
178 Clazz.defineMethod (c$, "getTranslation",
\r
180 trans.x = this.m03;
\r
181 trans.y = this.m13;
\r
182 trans.z = this.m23;
\r
183 }, "javajs.util.T3");
\r
184 Clazz.defineMethod (c$, "getRotationScale",
\r
195 }, "javajs.util.M3");
\r
196 Clazz.defineMethod (c$, "setRotationScale",
\r
207 }, "javajs.util.M3");
\r
208 Clazz.defineMethod (c$, "setRowA",
\r
209 function (row, v) {
\r
210 if (row < 3) this.setRow33 (row, v);
\r
230 Clazz.overrideMethod (c$, "getRow",
\r
231 function (row, v) {
\r
232 if (row < 3) this.getRow33 (row, v);
\r
252 Clazz.defineMethod (c$, "setColumn4",
\r
253 function (column, x, y, z, w) {
\r
259 } else if (column == 1) {
\r
264 } else if (column == 2) {
\r
269 } else if (column == 3) {
\r
276 }}, "~N,~N,~N,~N,~N");
\r
277 Clazz.defineMethod (c$, "setColumnA",
\r
278 function (column, v) {
\r
279 if (column < 3) this.setColumn33 (column, v);
\r
300 Clazz.defineMethod (c$, "getColumn",
\r
301 function (column, v) {
\r
302 if (column < 3) this.getColumn33 (column, v);
\r
323 Clazz.defineMethod (c$, "sub",
\r
326 this.m03 -= m1.m03;
\r
327 this.m13 -= m1.m13;
\r
328 this.m23 -= m1.m23;
\r
329 this.m30 -= m1.m30;
\r
330 this.m31 -= m1.m31;
\r
331 this.m32 -= m1.m32;
\r
332 this.m33 -= m1.m33;
\r
333 }, "javajs.util.M4");
\r
334 Clazz.defineMethod (c$, "transpose",
\r
336 this.transpose33 ();
\r
337 var tmp = this.m03;
\r
338 this.m03 = this.m30;
\r
341 this.m13 = this.m31;
\r
344 this.m23 = this.m32;
\r
347 Clazz.defineMethod (c$, "invert",
\r
349 var s = this.determinant4 ();
\r
350 if (s == 0.0) return this;
\r
352 this.set (this.m11 * (this.m22 * this.m33 - this.m23 * this.m32) + this.m12 * (this.m23 * this.m31 - this.m21 * this.m33) + this.m13 * (this.m21 * this.m32 - this.m22 * this.m31), this.m21 * (this.m02 * this.m33 - this.m03 * this.m32) + this.m22 * (this.m03 * this.m31 - this.m01 * this.m33) + this.m23 * (this.m01 * this.m32 - this.m02 * this.m31), this.m31 * (this.m02 * this.m13 - this.m03 * this.m12) + this.m32 * (this.m03 * this.m11 - this.m01 * this.m13) + this.m33 * (this.m01 * this.m12 - this.m02 * this.m11), this.m01 * (this.m13 * this.m22 - this.m12 * this.m23) + this.m02 * (this.m11 * this.m23 - this.m13 * this.m21) + this.m03 * (this.m12 * this.m21 - this.m11 * this.m22), this.m12 * (this.m20 * this.m33 - this.m23 * this.m30) + this.m13 * (this.m22 * this.m30 - this.m20 * this.m32) + this.m10 * (this.m23 * this.m32 - this.m22 * this.m33), this.m22 * (this.m00 * this.m33 - this.m03 * this.m30) + this.m23 * (this.m02 * this.m30 - this.m00 * this.m32) + this.m20 * (this.m03 * this.m32 - this.m02 * this.m33), this.m32 * (this.m00 * this.m13 - this.m03 * this.m10) + this.m33 * (this.m02 * this.m10 - this.m00 * this.m12) + this.m30 * (this.m03 * this.m12 - this.m02 * this.m13), this.m02 * (this.m13 * this.m20 - this.m10 * this.m23) + this.m03 * (this.m10 * this.m22 - this.m12 * this.m20) + this.m00 * (this.m12 * this.m23 - this.m13 * this.m22), this.m13 * (this.m20 * this.m31 - this.m21 * this.m30) + this.m10 * (this.m21 * this.m33 - this.m23 * this.m31) + this.m11 * (this.m23 * this.m30 - this.m20 * this.m33), this.m23 * (this.m00 * this.m31 - this.m01 * this.m30) + this.m20 * (this.m01 * this.m33 - this.m03 * this.m31) + this.m21 * (this.m03 * this.m30 - this.m00 * this.m33), this.m33 * (this.m00 * this.m11 - this.m01 * this.m10) + this.m30 * (this.m01 * this.m13 - this.m03 * this.m11) + this.m31 * (this.m03 * this.m10 - this.m00 * this.m13), this.m03 * (this.m11 * this.m20 - this.m10 * this.m21) + this.m00 * (this.m13 * this.m21 - this.m11 * this.m23) + this.m01 * (this.m10 * this.m23 - this.m13 * this.m20), this.m10 * (this.m22 * this.m31 - this.m21 * this.m32) + this.m11 * (this.m20 * this.m32 - this.m22 * this.m30) + this.m12 * (this.m21 * this.m30 - this.m20 * this.m31), this.m20 * (this.m02 * this.m31 - this.m01 * this.m32) + this.m21 * (this.m00 * this.m32 - this.m02 * this.m30) + this.m22 * (this.m01 * this.m30 - this.m00 * this.m31), this.m30 * (this.m02 * this.m11 - this.m01 * this.m12) + this.m31 * (this.m00 * this.m12 - this.m02 * this.m10) + this.m32 * (this.m01 * this.m10 - this.m00 * this.m11), this.m00 * (this.m11 * this.m22 - this.m12 * this.m21) + this.m01 * (this.m12 * this.m20 - this.m10 * this.m22) + this.m02 * (this.m10 * this.m21 - this.m11 * this.m20));
\r
356 Clazz.defineMethod (c$, "set",
\r
357 ($fz = function (m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
\r
374 }, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N,~N");
\r
375 Clazz.defineMethod (c$, "determinant4",
\r
377 return (this.m00 * this.m11 - this.m01 * this.m10) * (this.m22 * this.m33 - this.m23 * this.m32) - (this.m00 * this.m12 - this.m02 * this.m10) * (this.m21 * this.m33 - this.m23 * this.m31) + (this.m00 * this.m13 - this.m03 * this.m10) * (this.m21 * this.m32 - this.m22 * this.m31) + (this.m01 * this.m12 - this.m02 * this.m11) * (this.m20 * this.m33 - this.m23 * this.m30) - (this.m01 * this.m13 - this.m03 * this.m11) * (this.m20 * this.m32 - this.m22 * this.m30) + (this.m02 * this.m13 - this.m03 * this.m12) * (this.m20 * this.m31 - this.m21 * this.m30);
\r
379 Clazz.defineMethod (c$, "scale",
\r
380 ($fz = function (scalar) {
\r
381 this.mul33 (scalar);
\r
382 this.m03 *= scalar;
\r
383 this.m13 *= scalar;
\r
384 this.m23 *= scalar;
\r
385 this.m30 *= scalar;
\r
386 this.m31 *= scalar;
\r
387 this.m32 *= scalar;
\r
388 this.m33 *= scalar;
\r
389 }, $fz.isPrivate = true, $fz), "~N");
\r
390 Clazz.defineMethod (c$, "mul",
\r
392 this.mul2 (this, m1);
\r
393 }, "javajs.util.M4");
\r
394 Clazz.defineMethod (c$, "mul2",
\r
395 function (m1, m2) {
\r
396 this.set (m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20 + m1.m03 * m2.m30, m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21 + m1.m03 * m2.m31, m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22 + m1.m03 * m2.m32, m1.m00 * m2.m03 + m1.m01 * m2.m13 + m1.m02 * m2.m23 + m1.m03 * m2.m33, m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20 + m1.m13 * m2.m30, m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21 + m1.m13 * m2.m31, m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22 + m1.m13 * m2.m32, m1.m10 * m2.m03 + m1.m11 * m2.m13 + m1.m12 * m2.m23 + m1.m13 * m2.m33, m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20 + m1.m23 * m2.m30, m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21 + m1.m23 * m2.m31, m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22 + m1.m23 * m2.m32, m1.m20 * m2.m03 + m1.m21 * m2.m13 + m1.m22 * m2.m23 + m1.m23 * m2.m33, m1.m30 * m2.m00 + m1.m31 * m2.m10 + m1.m32 * m2.m20 + m1.m33 * m2.m30, m1.m30 * m2.m01 + m1.m31 * m2.m11 + m1.m32 * m2.m21 + m1.m33 * m2.m31, m1.m30 * m2.m02 + m1.m31 * m2.m12 + m1.m32 * m2.m22 + m1.m33 * m2.m32, m1.m30 * m2.m03 + m1.m31 * m2.m13 + m1.m32 * m2.m23 + m1.m33 * m2.m33);
\r
397 }, "javajs.util.M4,javajs.util.M4");
\r
398 Clazz.defineMethod (c$, "transform",
\r
400 this.transform2 (vec, vec);
\r
401 }, "javajs.util.T4");
\r
402 Clazz.defineMethod (c$, "transform2",
\r
403 function (vec, vecOut) {
\r
404 vecOut.set4 (this.m00 * vec.x + this.m01 * vec.y + this.m02 * vec.z + this.m03 * vec.w, this.m10 * vec.x + this.m11 * vec.y + this.m12 * vec.z + this.m13 * vec.w, this.m20 * vec.x + this.m21 * vec.y + this.m22 * vec.z + this.m23 * vec.w, this.m30 * vec.x + this.m31 * vec.y + this.m32 * vec.z + this.m33 * vec.w);
\r
405 }, "javajs.util.T4,javajs.util.T4");
\r
406 Clazz.defineMethod (c$, "rotTrans",
\r
408 this.rotTrans2 (point, point);
\r
409 }, "javajs.util.T3");
\r
410 Clazz.defineMethod (c$, "rotTrans2",
\r
411 function (point, pointOut) {
\r
412 pointOut.set (this.m00 * point.x + this.m01 * point.y + this.m02 * point.z + this.m03, this.m10 * point.x + this.m11 * point.y + this.m12 * point.z + this.m13, this.m20 * point.x + this.m21 * point.y + this.m22 * point.z + this.m23);
\r
414 }, "javajs.util.T3,javajs.util.T3");
\r
415 Clazz.defineMethod (c$, "setAsXYRotation",
\r
417 this.setIdentity ();
\r
418 var c = Math.cos (angle);
\r
419 var s = Math.sin (angle);
\r
426 Clazz.defineMethod (c$, "setAsYZRotation",
\r
428 this.setIdentity ();
\r
429 var c = Math.cos (angle);
\r
430 var s = Math.sin (angle);
\r
437 Clazz.defineMethod (c$, "setAsXZRotation",
\r
439 this.setIdentity ();
\r
440 var c = Math.cos (angle);
\r
441 var s = Math.sin (angle);
\r
448 Clazz.overrideMethod (c$, "equals",
\r
450 if (!(Clazz.instanceOf (o, javajs.util.M4))) return false;
\r
452 return (this.m00 == m.m00 && this.m01 == m.m01 && this.m02 == m.m02 && this.m03 == m.m03 && this.m10 == m.m10 && this.m11 == m.m11 && this.m12 == m.m12 && this.m13 == m.m13 && this.m20 == m.m20 && this.m21 == m.m21 && this.m22 == m.m22 && this.m23 == m.m23 && this.m30 == m.m30 && this.m31 == m.m31 && this.m32 == m.m32 && this.m33 == m.m33);
\r
454 Clazz.overrideMethod (c$, "hashCode",
\r
456 return javajs.util.T3.floatToIntBits0 (this.m00) ^ javajs.util.T3.floatToIntBits0 (this.m01) ^ javajs.util.T3.floatToIntBits0 (this.m02) ^ javajs.util.T3.floatToIntBits0 (this.m03) ^ javajs.util.T3.floatToIntBits0 (this.m10) ^ javajs.util.T3.floatToIntBits0 (this.m11) ^ javajs.util.T3.floatToIntBits0 (this.m12) ^ javajs.util.T3.floatToIntBits0 (this.m13) ^ javajs.util.T3.floatToIntBits0 (this.m20) ^ javajs.util.T3.floatToIntBits0 (this.m21) ^ javajs.util.T3.floatToIntBits0 (this.m22) ^ javajs.util.T3.floatToIntBits0 (this.m23) ^ javajs.util.T3.floatToIntBits0 (this.m30) ^ javajs.util.T3.floatToIntBits0 (this.m31) ^ javajs.util.T3.floatToIntBits0 (this.m32) ^ javajs.util.T3.floatToIntBits0 (this.m33);
\r
458 Clazz.overrideMethod (c$, "toString",
\r
460 return "[\n [" + this.m00 + "\t" + this.m01 + "\t" + this.m02 + "\t" + this.m03 + "]" + "\n [" + this.m10 + "\t" + this.m11 + "\t" + this.m12 + "\t" + this.m13 + "]" + "\n [" + this.m20 + "\t" + this.m21 + "\t" + this.m22 + "\t" + this.m23 + "]" + "\n [" + this.m30 + "\t" + this.m31 + "\t" + this.m32 + "\t" + this.m33 + "] ]";
\r
462 Clazz.defineMethod (c$, "round",
\r
464 this.m00 = this.rnd (this.m00, f);
\r
465 this.m01 = this.rnd (this.m01, f);
\r
466 this.m02 = this.rnd (this.m02, f);
\r
467 this.m03 = this.rnd (this.m03, f);
\r
468 this.m10 = this.rnd (this.m10, f);
\r
469 this.m11 = this.rnd (this.m11, f);
\r
470 this.m12 = this.rnd (this.m12, f);
\r
471 this.m13 = this.rnd (this.m13, f);
\r
472 this.m20 = this.rnd (this.m20, f);
\r
473 this.m21 = this.rnd (this.m21, f);
\r
474 this.m22 = this.rnd (this.m22, f);
\r
475 this.m23 = this.rnd (this.m23, f);
\r
476 this.m30 = this.rnd (this.m30, f);
\r
477 this.m31 = this.rnd (this.m31, f);
\r
478 this.m32 = this.rnd (this.m32, f);
\r
479 this.m33 = this.rnd (this.m33, f);
\r
482 Clazz.defineMethod (c$, "rnd",
\r
483 ($fz = function (n, f) {
\r
484 return (Math.abs (n) < f ? 0 : n);
\r
485 }, $fz.isPrivate = true, $fz), "~N,~N");
\r