1 Clazz.declarePackage ("JU");
2 Clazz.load (["javajs.api.JSONEncodable"], "JU.T3", ["java.lang.Float"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 Clazz.instantialize (this, arguments);
8 }, JU, "T3", null, [javajs.api.JSONEncodable, java.io.Serializable]);
9 Clazz.defineMethod (c$, "set",
15 Clazz.defineMethod (c$, "setA",
21 Clazz.defineMethod (c$, "setT",
27 Clazz.defineMethod (c$, "add2",
33 Clazz.defineMethod (c$, "add",
39 Clazz.defineMethod (c$, "distanceSquared",
41 var dx = this.x - p1.x;
42 var dy = this.y - p1.y;
43 var dz = this.z - p1.z;
44 return (dx * dx + dy * dy + dz * dz);
46 Clazz.defineMethod (c$, "distance",
48 return Math.sqrt (this.distanceSquared (p1));
50 Clazz.defineMethod (c$, "sub2",
56 Clazz.defineMethod (c$, "sub",
62 Clazz.defineMethod (c$, "scale",
68 Clazz.defineMethod (c$, "add3",
74 Clazz.defineMethod (c$, "scaleT",
80 Clazz.defineMethod (c$, "scaleAdd2",
81 function (s, t1, t2) {
82 this.x = s * t1.x + t2.x;
83 this.y = s * t1.y + t2.y;
84 this.z = s * t1.z + t2.z;
86 Clazz.defineMethod (c$, "ave",
88 this.x = (a.x + b.x) / 2;
89 this.y = (a.y + b.y) / 2;
90 this.z = (a.z + b.z) / 2;
92 Clazz.defineMethod (c$, "dot",
94 return this.x * v.x + this.y * v.y + this.z * v.z;
96 Clazz.defineMethod (c$, "lengthSquared",
98 return this.x * this.x + this.y * this.y + this.z * this.z;
100 Clazz.defineMethod (c$, "length",
102 return Math.sqrt (this.lengthSquared ());
104 Clazz.defineMethod (c$, "normalize",
106 var d = this.length ();
111 Clazz.defineMethod (c$, "cross",
113 this.set (v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x);
115 Clazz.overrideMethod (c$, "hashCode",
118 bits = 31 * bits + JU.T3.floatToIntBits0 (this.x);
119 bits = 31 * bits + JU.T3.floatToIntBits0 (this.y);
120 bits = 31 * bits + JU.T3.floatToIntBits0 (this.z);
121 return (bits ^ (bits >> 32));
123 c$.floatToIntBits0 = Clazz.defineMethod (c$, "floatToIntBits0",
125 return (f == 0 ? 0 : Float.floatToIntBits (f));
127 Clazz.overrideMethod (c$, "equals",
129 if (!(Clazz.instanceOf (t1, JU.T3))) return false;
131 return (this.x == t2.x && this.y == t2.y && this.z == t2.z);
133 Clazz.overrideMethod (c$, "toString",
135 return "{" + this.x + ", " + this.y + ", " + this.z + "}";
137 Clazz.overrideMethod (c$, "toJSON",
139 return "[" + this.x + "," + this.y + "," + this.z + "]";