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