Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / JU / V3.js
1 Clazz.declarePackage ("JU");
2 Clazz.load (["JU.T3"], "JU.V3", null, function () {
3 c$ = Clazz.declareType (JU, "V3", JU.T3);
4 Clazz.makeConstructor (c$, 
5 function () {
6 });
7 c$.newV = Clazz.defineMethod (c$, "newV", 
8 function (t) {
9 return JU.V3.new3 (t.x, t.y, t.z);
10 }, "JU.T3");
11 c$.newVsub = Clazz.defineMethod (c$, "newVsub", 
12 function (t1, t2) {
13 return JU.V3.new3 (t1.x - t2.x, t1.y - t2.y, t1.z - t2.z);
14 }, "JU.T3,JU.T3");
15 c$.new3 = Clazz.defineMethod (c$, "new3", 
16 function (x, y, z) {
17 var v =  new JU.V3 ();
18 v.x = x;
19 v.y = y;
20 v.z = z;
21 return v;
22 }, "~N,~N,~N");
23 Clazz.defineMethod (c$, "angle", 
24 function (v1) {
25 var xx = this.y * v1.z - this.z * v1.y;
26 var yy = this.z * v1.x - this.x * v1.z;
27 var zz = this.x * v1.y - this.y * v1.x;
28 var cross = Math.sqrt (xx * xx + yy * yy + zz * zz);
29 return Math.abs (Math.atan2 (cross, this.dot (v1)));
30 }, "JU.V3");
31 });