80234ebd37343e38564689e3b809d74499c08a9e
[jalviewjs.git] / site / swingjs / j2s / JU / V3d.js
1 Clazz.declarePackage ("JU");
2 Clazz.load (["JU.T3d"], "JU.V3d", null, function () {
3 c$ = Clazz.declareType (JU, "V3d", JU.T3d);
4 Clazz.defineMethod (c$, "cross", 
5 function (v1, v2) {
6 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);
7 }, "JU.V3d,JU.V3d");
8 Clazz.defineMethod (c$, "normalize", 
9 function () {
10 var d = this.length ();
11 this.x /= d;
12 this.y /= d;
13 this.z /= d;
14 });
15 Clazz.defineMethod (c$, "dot", 
16 function (v) {
17 return this.x * v.x + this.y * v.y + this.z * v.z;
18 }, "JU.V3d");
19 Clazz.defineMethod (c$, "lengthSquared", 
20 function () {
21 return this.x * this.x + this.y * this.y + this.z * this.z;
22 });
23 Clazz.defineMethod (c$, "length", 
24 function () {
25 return Math.sqrt (this.lengthSquared ());
26 });
27 });