JAL-1807 test
[jalviewjs.git] / bin / javajs / util / M3.js
1 Clazz.declarePackage ("javajs.util");
2 Clazz.load (["javajs.util.M34"], "javajs.util.M3", ["javajs.util.T3"], function () {
3 c$ = Clazz.declareType (javajs.util, "M3", javajs.util.M34, java.io.Serializable);
4 c$.newA9 = Clazz.defineMethod (c$, "newA9", 
5 function (v) {
6 var m =  new javajs.util.M3 ();
7 m.setA (v);
8 return m;
9 }, "~A");
10 c$.newM3 = Clazz.defineMethod (c$, "newM3", 
11 function (m1) {
12 var m =  new javajs.util.M3 ();
13 if (m1 == null) {
14 m.setScale (1);
15 return m;
16 }m.m00 = m1.m00;
17 m.m01 = m1.m01;
18 m.m02 = m1.m02;
19 m.m10 = m1.m10;
20 m.m11 = m1.m11;
21 m.m12 = m1.m12;
22 m.m20 = m1.m20;
23 m.m21 = m1.m21;
24 m.m22 = m1.m22;
25 return m;
26 }, "javajs.util.M3");
27 Clazz.defineMethod (c$, "setScale", 
28 function (scale) {
29 this.clear33 ();
30 this.m00 = this.m11 = this.m22 = scale;
31 }, "~N");
32 Clazz.defineMethod (c$, "setM3", 
33 function (m1) {
34 this.setM33 (m1);
35 }, "javajs.util.M34");
36 Clazz.defineMethod (c$, "setA", 
37 function (m) {
38 this.m00 = m[0];
39 this.m01 = m[1];
40 this.m02 = m[2];
41 this.m10 = m[3];
42 this.m11 = m[4];
43 this.m12 = m[5];
44 this.m20 = m[6];
45 this.m21 = m[7];
46 this.m22 = m[8];
47 }, "~A");
48 Clazz.defineMethod (c$, "setElement", 
49 function (row, col, v) {
50 this.set33 (row, col, v);
51 }, "~N,~N,~N");
52 Clazz.defineMethod (c$, "getElement", 
53 function (row, col) {
54 return this.get33 (row, col);
55 }, "~N,~N");
56 Clazz.defineMethod (c$, "setRow", 
57 function (row, x, y, z) {
58 switch (row) {
59 case 0:
60 this.m00 = x;
61 this.m01 = y;
62 this.m02 = z;
63 return;
64 case 1:
65 this.m10 = x;
66 this.m11 = y;
67 this.m12 = z;
68 return;
69 case 2:
70 this.m20 = x;
71 this.m21 = y;
72 this.m22 = z;
73 return;
74 default:
75 this.err ();
76 }
77 }, "~N,~N,~N,~N");
78 Clazz.defineMethod (c$, "setRowV", 
79 function (row, v) {
80 switch (row) {
81 case 0:
82 this.m00 = v.x;
83 this.m01 = v.y;
84 this.m02 = v.z;
85 return;
86 case 1:
87 this.m10 = v.x;
88 this.m11 = v.y;
89 this.m12 = v.z;
90 return;
91 case 2:
92 this.m20 = v.x;
93 this.m21 = v.y;
94 this.m22 = v.z;
95 return;
96 default:
97 this.err ();
98 }
99 }, "~N,javajs.util.T3");
100 Clazz.defineMethod (c$, "setRowA", 
101 function (row, v) {
102 this.setRow33 (row, v);
103 }, "~N,~A");
104 Clazz.overrideMethod (c$, "getRow", 
105 function (row, v) {
106 this.getRow33 (row, v);
107 }, "~N,~A");
108 Clazz.defineMethod (c$, "setColumn3", 
109 function (column, x, y, z) {
110 switch (column) {
111 case 0:
112 this.m00 = x;
113 this.m10 = y;
114 this.m20 = z;
115 break;
116 case 1:
117 this.m01 = x;
118 this.m11 = y;
119 this.m21 = z;
120 break;
121 case 2:
122 this.m02 = x;
123 this.m12 = y;
124 this.m22 = z;
125 break;
126 default:
127 this.err ();
128 }
129 }, "~N,~N,~N,~N");
130 Clazz.defineMethod (c$, "setColumnV", 
131 function (column, v) {
132 switch (column) {
133 case 0:
134 this.m00 = v.x;
135 this.m10 = v.y;
136 this.m20 = v.z;
137 break;
138 case 1:
139 this.m01 = v.x;
140 this.m11 = v.y;
141 this.m21 = v.z;
142 break;
143 case 2:
144 this.m02 = v.x;
145 this.m12 = v.y;
146 this.m22 = v.z;
147 break;
148 default:
149 this.err ();
150 }
151 }, "~N,javajs.util.T3");
152 Clazz.defineMethod (c$, "getColumnV", 
153 function (column, v) {
154 switch (column) {
155 case 0:
156 v.x = this.m00;
157 v.y = this.m10;
158 v.z = this.m20;
159 break;
160 case 1:
161 v.x = this.m01;
162 v.y = this.m11;
163 v.z = this.m21;
164 break;
165 case 2:
166 v.x = this.m02;
167 v.y = this.m12;
168 v.z = this.m22;
169 break;
170 default:
171 this.err ();
172 }
173 }, "~N,javajs.util.T3");
174 Clazz.defineMethod (c$, "setColumnA", 
175 function (column, v) {
176 this.setColumn33 (column, v);
177 }, "~N,~A");
178 Clazz.defineMethod (c$, "getColumn", 
179 function (column, v) {
180 this.getColumn33 (column, v);
181 }, "~N,~A");
182 Clazz.defineMethod (c$, "add", 
183 function (m1) {
184 this.add33 (m1);
185 }, "javajs.util.M3");
186 Clazz.defineMethod (c$, "sub", 
187 function (m1) {
188 this.sub33 (m1);
189 }, "javajs.util.M3");
190 Clazz.defineMethod (c$, "transpose", 
191 function () {
192 this.transpose33 ();
193 });
194 Clazz.defineMethod (c$, "transposeM", 
195 function (m1) {
196 this.setM33 (m1);
197 this.transpose33 ();
198 }, "javajs.util.M3");
199 Clazz.defineMethod (c$, "invertM", 
200 function (m1) {
201 this.setM33 (m1);
202 this.invert ();
203 }, "javajs.util.M3");
204 Clazz.defineMethod (c$, "invert", 
205 function () {
206 var s = this.determinant3 ();
207 if (s == 0.0) return;
208 s = 1 / s;
209 this.set9 (this.m11 * this.m22 - this.m12 * this.m21, this.m02 * this.m21 - this.m01 * this.m22, this.m01 * this.m12 - this.m02 * this.m11, this.m12 * this.m20 - this.m10 * this.m22, this.m00 * this.m22 - this.m02 * this.m20, this.m02 * this.m10 - this.m00 * this.m12, this.m10 * this.m21 - this.m11 * this.m20, this.m01 * this.m20 - this.m00 * this.m21, this.m00 * this.m11 - this.m01 * this.m10);
210 this.scale (s);
211 });
212 Clazz.defineMethod (c$, "setAsXRotation", 
213 function (angle) {
214 this.setXRot (angle);
215 return this;
216 }, "~N");
217 Clazz.defineMethod (c$, "setAsYRotation", 
218 function (angle) {
219 this.setYRot (angle);
220 return this;
221 }, "~N");
222 Clazz.defineMethod (c$, "setAsZRotation", 
223 function (angle) {
224 this.setZRot (angle);
225 return this;
226 }, "~N");
227 Clazz.defineMethod (c$, "scale", 
228 function (scalar) {
229 this.mul33 (scalar);
230 }, "~N");
231 Clazz.defineMethod (c$, "mul", 
232 function (m1) {
233 this.mul2 (this, m1);
234 }, "javajs.util.M3");
235 Clazz.defineMethod (c$, "mul2", 
236 function (m1, m2) {
237 this.set9 (m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20, m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21, m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22, m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20, m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21, m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22, m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20, m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21, m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22);
238 }, "javajs.util.M3,javajs.util.M3");
239 Clazz.overrideMethod (c$, "equals", 
240 function (o) {
241 if (!(Clazz.instanceOf (o, javajs.util.M3))) return false;
242 var m = o;
243 return this.m00 == m.m00 && this.m01 == m.m01 && this.m02 == m.m02 && this.m10 == m.m10 && this.m11 == m.m11 && this.m12 == m.m12 && this.m20 == m.m20 && this.m21 == m.m21 && this.m22 == m.m22;
244 }, "~O");
245 Clazz.overrideMethod (c$, "hashCode", 
246 function () {
247 return javajs.util.T3.floatToIntBits0 (this.m00) ^ javajs.util.T3.floatToIntBits0 (this.m01) ^ javajs.util.T3.floatToIntBits0 (this.m02) ^ javajs.util.T3.floatToIntBits0 (this.m10) ^ javajs.util.T3.floatToIntBits0 (this.m11) ^ javajs.util.T3.floatToIntBits0 (this.m12) ^ javajs.util.T3.floatToIntBits0 (this.m20) ^ javajs.util.T3.floatToIntBits0 (this.m21) ^ javajs.util.T3.floatToIntBits0 (this.m22);
248 });
249 Clazz.defineMethod (c$, "setZero", 
250 function () {
251 this.clear33 ();
252 });
253 Clazz.defineMethod (c$, "set9", 
254 ($fz = function (m00, m01, m02, m10, m11, m12, m20, m21, m22) {
255 this.m00 = m00;
256 this.m01 = m01;
257 this.m02 = m02;
258 this.m10 = m10;
259 this.m11 = m11;
260 this.m12 = m12;
261 this.m20 = m20;
262 this.m21 = m21;
263 this.m22 = m22;
264 }, $fz.isPrivate = true, $fz), "~N,~N,~N,~N,~N,~N,~N,~N,~N");
265 Clazz.overrideMethod (c$, "toString", 
266 function () {
267 return "[\n  [" + this.m00 + "\t" + this.m01 + "\t" + this.m02 + "]" + "\n  [" + this.m10 + "\t" + this.m11 + "\t" + this.m12 + "]" + "\n  [" + this.m20 + "\t" + this.m21 + "\t" + this.m22 + "] ]";
268 });
269 Clazz.defineMethod (c$, "setAA", 
270 function (a) {
271 this.setAA33 (a);
272 return this;
273 }, "javajs.util.A4");
274 Clazz.defineMethod (c$, "setAsBallRotation", 
275 function (responseFactor, dx, dy) {
276 var r = Math.sqrt (dx * dx + dy * dy);
277 var th = r * responseFactor;
278 if (th == 0) {
279 this.setScale (1);
280 return false;
281 }var c = Math.cos (th);
282 var s = Math.sin (th);
283 var nx = -dy / r;
284 var ny = dx / r;
285 var c1 = c - 1;
286 this.m00 = 1 + c1 * nx * nx;
287 this.m01 = this.m10 = c1 * nx * ny;
288 this.m20 = -(this.m02 = s * nx);
289 this.m11 = 1 + c1 * ny * ny;
290 this.m21 = -(this.m12 = s * ny);
291 this.m22 = c;
292 return true;
293 }, "~N,~N,~N");
294 Clazz.defineMethod (c$, "isRotation", 
295 function () {
296 return (Math.abs (this.determinant3 () - 1) < 0.001);
297 });
298 });