diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/mat4.js | 192 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/quat.js | 64 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec2.js | 6 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec3.js | 18 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec4.js | 46 |
5 files changed, 163 insertions, 163 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/math/mat4.js b/js/helper-classes/RDGE/src/core/script/math/mat4.js index 32c7111c..e2907272 100755 --- a/js/helper-classes/RDGE/src/core/script/math/mat4.js +++ b/js/helper-classes/RDGE/src/core/script/math/mat4.js | |||
@@ -33,21 +33,21 @@ POSSIBILITY OF SUCH DAMAGE. | |||
33 | * containing at least 16 numeric components can represent a 4x4 matrix. | 33 | * containing at least 16 numeric components can represent a 4x4 matrix. |
34 | * | 34 | * |
35 | * For example, all of these are valid matrix construction methods: | 35 | * For example, all of these are valid matrix construction methods: |
36 | * ... | 36 | * ... |
37 | * var a = mat4.identity(); | 37 | * var a = mat4.identity(); |
38 | * var b = mat4.perspective(90, aspectRatio, 0.1, 100.00); | 38 | * var b = mat4.perspective(90, aspectRatio, 0.1, 100.00); |
39 | * var c = mat4.lookAt( [0, 0, 0], [1, 0, 0], [ 0, 1, 0 ] ); | 39 | * var c = mat4.lookAt( [0, 0, 0], [1, 0, 0], [ 0, 1, 0 ] ); |
40 | * var d = mat4.basis( [1, 0, 0], [0, 1, 0], [ 0, 0, 1 ] ); | 40 | * var d = mat4.basis( [1, 0, 0], [0, 1, 0], [ 0, 0, 1 ] ); |
41 | * | 41 | * |
42 | * This library is implemented assuming components are arranged | 42 | * This library is implemented assuming components are arranged |
43 | * contiguously in memory as such: | 43 | * contiguously in memory as such: |
44 | * M = [ x0, x1, x2, x3, | 44 | * M = [ x0, x1, x2, x3, |
45 | * y0, y1, y2, y3, | 45 | * y0, y1, y2, y3, |
46 | * z0, z1, z2, z3, | 46 | * z0, z1, z2, z3, |
47 | * w0, w1, w2, w3 ]; | 47 | * w0, w1, w2, w3 ]; |
48 | * The translation components of a transformation matrix would be stored in | 48 | * The translation components of a transformation matrix would be stored in |
49 | * w0, w1, w2, or at indices 12, 13, and 14 of the array, as is consistent | 49 | * w0, w1, w2, or at indices 12, 13, and 14 of the array, as is consistent |
50 | * with OpenGL. | 50 | * with OpenGL. |
51 | */ | 51 | */ |
52 | // RDGE namespaces | 52 | // RDGE namespaces |
53 | var RDGE = RDGE || {}; | 53 | var RDGE = RDGE || {}; |
@@ -102,9 +102,9 @@ RDGE.mat4.verify = function (m) { | |||
102 | */ | 102 | */ |
103 | RDGE.mat4.copy = function (m) { | 103 | RDGE.mat4.copy = function (m) { |
104 | return [m[0], m[1], m[2], m[3], | 104 | return [m[0], m[1], m[2], m[3], |
105 | m[4], m[5], m[6], m[7], | 105 | m[4], m[5], m[6], m[7], |
106 | m[8], m[9], m[10], m[11], | 106 | m[8], m[9], m[10], m[11], |
107 | m[12], m[13], m[14], m[15]]; | 107 | m[12], m[13], m[14], m[15]]; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | /** | 110 | /** |
@@ -134,9 +134,9 @@ RDGE.mat4.inplace_copy = function (dst, src) { | |||
134 | */ | 134 | */ |
135 | RDGE.mat4.identity = function () { | 135 | RDGE.mat4.identity = function () { |
136 | return [1.0, 0.0, 0.0, 0.0, | 136 | return [1.0, 0.0, 0.0, 0.0, |
137 | 0.0, 1.0, 0.0, 0.0, | 137 | 0.0, 1.0, 0.0, 0.0, |
138 | 0.0, 0.0, 1.0, 0.0, | 138 | 0.0, 0.0, 1.0, 0.0, |
139 | 0.0, 0.0, 0.0, 1.0]; | 139 | 0.0, 0.0, 0.0, 1.0]; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | /** | 142 | /** |
@@ -144,9 +144,9 @@ RDGE.mat4.identity = function () { | |||
144 | */ | 144 | */ |
145 | RDGE.mat4.zero = function () { | 145 | RDGE.mat4.zero = function () { |
146 | return [0.0, 0.0, 0.0, 0.0, | 146 | return [0.0, 0.0, 0.0, 0.0, |
147 | 0.0, 0.0, 0.0, 0.0, | 147 | 0.0, 0.0, 0.0, 0.0, |
148 | 0.0, 0.0, 0.0, 0.0, | 148 | 0.0, 0.0, 0.0, 0.0, |
149 | 0.0, 0.0, 0.0, 0.0]; | 149 | 0.0, 0.0, 0.0, 0.0]; |
150 | }; | 150 | }; |
151 | 151 | ||
152 | /** | 152 | /** |
@@ -156,14 +156,14 @@ RDGE.mat4.zero = function () { | |||
156 | RDGE.mat4.basis = function (rowx, rowy, rowz, roww) { | 156 | RDGE.mat4.basis = function (rowx, rowy, rowz, roww) { |
157 | if (roww == null || roww == undefined) { | 157 | if (roww == null || roww == undefined) { |
158 | return [rowx[0], rowx[1], rowx[2], 0.0, | 158 | return [rowx[0], rowx[1], rowx[2], 0.0, |
159 | rowy[0], rowy[1], rowy[2], 0.0, | 159 | rowy[0], rowy[1], rowy[2], 0.0, |
160 | rowz[0], rowz[1], rowz[2], 0.0, | 160 | rowz[0], rowz[1], rowz[2], 0.0, |
161 | 0, 0, 0, 1.0]; | 161 | 0, 0, 0, 1.0]; |
162 | } else { | 162 | } else { |
163 | return [rowx[0], rowx[1], rowx[2], rowx.length == 4 ? rowx[3] : 0.0, | 163 | return [rowx[0], rowx[1], rowx[2], rowx.length == 4 ? rowx[3] : 0.0, |
164 | rowy[0], rowy[1], rowy[2], rowy.length == 4 ? rowy[3] : 0.0, | 164 | rowy[0], rowy[1], rowy[2], rowy.length == 4 ? rowy[3] : 0.0, |
165 | rowz[0], rowz[1], rowz[2], rowz.length == 4 ? rowz[3] : 0.0, | 165 | rowz[0], rowz[1], rowz[2], rowz.length == 4 ? rowz[3] : 0.0, |
166 | roww[0], roww[1], roww[2], roww.length == 4 ? roww[3] : 1.0]; | 166 | roww[0], roww[1], roww[2], roww.length == 4 ? roww[3] : 1.0]; |
167 | } | 167 | } |
168 | }; | 168 | }; |
169 | 169 | ||
@@ -353,24 +353,24 @@ RDGE.mat4.mul = function (a, b) { | |||
353 | var b15 = b[15]; | 353 | var b15 = b[15]; |
354 | 354 | ||
355 | return [a00 * b00 + a01 * b04 + a02 * b08 + a03 * b12, | 355 | return [a00 * b00 + a01 * b04 + a02 * b08 + a03 * b12, |
356 | a00 * b01 + a01 * b05 + a02 * b09 + a03 * b13, | 356 | a00 * b01 + a01 * b05 + a02 * b09 + a03 * b13, |
357 | a00 * b02 + a01 * b06 + a02 * b10 + a03 * b14, | 357 | a00 * b02 + a01 * b06 + a02 * b10 + a03 * b14, |
358 | a00 * b03 + a01 * b07 + a02 * b11 + a03 * b15, | 358 | a00 * b03 + a01 * b07 + a02 * b11 + a03 * b15, |
359 | 359 | ||
360 | a04 * b00 + a05 * b04 + a06 * b08 + a07 * b12, | 360 | a04 * b00 + a05 * b04 + a06 * b08 + a07 * b12, |
361 | a04 * b01 + a05 * b05 + a06 * b09 + a07 * b13, | 361 | a04 * b01 + a05 * b05 + a06 * b09 + a07 * b13, |
362 | a04 * b02 + a05 * b06 + a06 * b10 + a07 * b14, | 362 | a04 * b02 + a05 * b06 + a06 * b10 + a07 * b14, |
363 | a04 * b03 + a05 * b07 + a06 * b11 + a07 * b15, | 363 | a04 * b03 + a05 * b07 + a06 * b11 + a07 * b15, |
364 | 364 | ||
365 | a08 * b00 + a09 * b04 + a10 * b08 + a11 * b12, | 365 | a08 * b00 + a09 * b04 + a10 * b08 + a11 * b12, |
366 | a08 * b01 + a09 * b05 + a10 * b09 + a11 * b13, | 366 | a08 * b01 + a09 * b05 + a10 * b09 + a11 * b13, |
367 | a08 * b02 + a09 * b06 + a10 * b10 + a11 * b14, | 367 | a08 * b02 + a09 * b06 + a10 * b10 + a11 * b14, |
368 | a08 * b03 + a09 * b07 + a10 * b11 + a11 * b15, | 368 | a08 * b03 + a09 * b07 + a10 * b11 + a11 * b15, |
369 | 369 | ||
370 | a12 * b00 + a13 * b04 + a14 * b08 + a15 * b12, | 370 | a12 * b00 + a13 * b04 + a14 * b08 + a15 * b12, |
371 | a12 * b01 + a13 * b05 + a14 * b09 + a15 * b13, | 371 | a12 * b01 + a13 * b05 + a14 * b09 + a15 * b13, |
372 | a12 * b02 + a13 * b06 + a14 * b10 + a15 * b14, | 372 | a12 * b02 + a13 * b06 + a14 * b10 + a15 * b14, |
373 | a12 * b03 + a13 * b07 + a14 * b11 + a15 * b15]; | 373 | a12 * b03 + a13 * b07 + a14 * b11 + a15 * b15]; |
374 | }; | 374 | }; |
375 | 375 | ||
376 | /** | 376 | /** |
@@ -409,24 +409,24 @@ RDGE.mat4.mul4x3 = function (a, b) { | |||
409 | var b14 = b[14]; | 409 | var b14 = b[14]; |
410 | 410 | ||
411 | return [a00 * b00 + a01 * b04 + a02 * b08, | 411 | return [a00 * b00 + a01 * b04 + a02 * b08, |
412 | a00 * b01 + a01 * b05 + a02 * b09, | 412 | a00 * b01 + a01 * b05 + a02 * b09, |
413 | a00 * b02 + a01 * b06 + a02 * b10, | 413 | a00 * b02 + a01 * b06 + a02 * b10, |
414 | 0, | 414 | 0, |
415 | 415 | ||
416 | a04 * b00 + a05 * b04 + a06 * b08, | 416 | a04 * b00 + a05 * b04 + a06 * b08, |
417 | a04 * b01 + a05 * b05 + a06 * b09, | 417 | a04 * b01 + a05 * b05 + a06 * b09, |
418 | a04 * b02 + a05 * b06 + a06 * b10, | 418 | a04 * b02 + a05 * b06 + a06 * b10, |
419 | 0, | 419 | 0, |
420 | 420 | ||
421 | a08 * b00 + a09 * b04 + a10 * b08, | 421 | a08 * b00 + a09 * b04 + a10 * b08, |
422 | a08 * b01 + a09 * b05 + a10 * b09, | 422 | a08 * b01 + a09 * b05 + a10 * b09, |
423 | a08 * b02 + a09 * b06 + a10 * b10, | 423 | a08 * b02 + a09 * b06 + a10 * b10, |
424 | 0, | 424 | 0, |
425 | 425 | ||
426 | a12 * b00 + a13 * b04 + a14 * b08 + b12, | 426 | a12 * b00 + a13 * b04 + a14 * b08 + b12, |
427 | a12 * b01 + a13 * b05 + a14 * b09 + b13, | 427 | a12 * b01 + a13 * b05 + a14 * b09 + b13, |
428 | a12 * b02 + a13 * b06 + a14 * b10 + b14, | 428 | a12 * b02 + a13 * b06 + a14 * b10 + b14, |
429 | 1.0]; | 429 | 1.0]; |
430 | }; | 430 | }; |
431 | 431 | ||
432 | /** | 432 | /** |
@@ -441,8 +441,8 @@ RDGE.mat4._det2x2 = function (a, b, c, d) { | |||
441 | */ | 441 | */ |
442 | RDGE.mat4._det3x3 = function (a1, a2, a3, b1, b2, b3, c1, c2, c3) { | 442 | RDGE.mat4._det3x3 = function (a1, a2, a3, b1, b2, b3, c1, c2, c3) { |
443 | return a1 * RDGE.mat4._det2x2(b2, b3, c2, c3) | 443 | return a1 * RDGE.mat4._det2x2(b2, b3, c2, c3) |
444 | - b1 * RDGE.mat4._det2x2(a2, a3, c2, c3) | 444 | - b1 * RDGE.mat4._det2x2(a2, a3, c2, c3) |
445 | + c1 * RDGE.mat4._det2x2(a2, a3, b2, b3); | 445 | + c1 * RDGE.mat4._det2x2(a2, a3, b2, b3); |
446 | }; | 446 | }; |
447 | 447 | ||
448 | /** | 448 | /** |
@@ -470,9 +470,9 @@ RDGE.mat4._det4x4 = function (m) { | |||
470 | var d4 = m[15]; | 470 | var d4 = m[15]; |
471 | 471 | ||
472 | return a1 * RDGE.mat4._det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) | 472 | return a1 * RDGE.mat4._det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) |
473 | - b1 * RDGE.mat4._det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) | 473 | - b1 * RDGE.mat4._det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) |
474 | + c1 * RDGE.mat4._det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) |