diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/mat4.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/mat4.js | 26 |
1 files changed, 13 insertions, 13 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 e2907272..d5cd7039 100755 --- a/js/helper-classes/RDGE/src/core/script/math/mat4.js +++ b/js/helper-classes/RDGE/src/core/script/math/mat4.js | |||
@@ -29,8 +29,8 @@ POSSIBILITY OF SUCH DAMAGE. | |||
29 | </copyright> */ | 29 | </copyright> */ |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * This library contains functions for operating on 4x4 matrices. Any JS array | 32 | * This library contains functions for operating on 4x4 matrices. Any JS array |
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 | * ... |
@@ -39,15 +39,15 @@ POSSIBILITY OF SUCH DAMAGE. | |||
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 || {}; |
@@ -81,7 +81,7 @@ RDGE.mat4.toCSSString = function (m, conversionConstant) { | |||
81 | 81 | ||
82 | /** | 82 | /** |
83 | * RDGE.mat4.verify | 83 | * RDGE.mat4.verify |
84 | * This function is provided for debugging purposes only. It is not recommended | 84 | * This function is provided for debugging purposes only. It is not recommended |
85 | * to be used in performance critical areas of the code. | 85 | * to be used in performance critical areas of the code. |
86 | */ | 86 | */ |
87 | RDGE.mat4.verify = function (m) { | 87 | RDGE.mat4.verify = function (m) { |
@@ -231,10 +231,10 @@ RDGE.mat4.angleAxis = function (angle, axis) { | |||
231 | RDGE.mat4.lookAt = function (eye, at, up) { | 231 | RDGE.mat4.lookAt = function (eye, at, up) { |
232 | /* | 232 | /* |
233 | var w_axis = new RDGE.vec3(posVec.x, posVec.y, posVec.z); | 233 | var w_axis = new RDGE.vec3(posVec.x, posVec.y, posVec.z); |
234 | 234 | ||
235 | var z_axis = subVec3(targetVec, w_axis); | 235 | var z_axis = subVec3(targetVec, w_axis); |
236 | z_axis.normalize(); | 236 | z_axis.normalize(); |
237 | 237 | ||
238 | var x_axis = crossVec3(upVec, z_axis); | 238 | var x_axis = crossVec3(upVec, z_axis); |
239 | x_axis.normalize(); | 239 | x_axis.normalize(); |
240 | 240 | ||
@@ -522,7 +522,7 @@ RDGE.mat4._adjoint = function (m) { | |||
522 | */ | 522 | */ |
523 | RDGE.mat4.inverse = function (m) { | 523 | RDGE.mat4.inverse = function (m) { |
524 | // Calculate the 4x4 determinant | 524 | // Calculate the 4x4 determinant |
525 | // If the determinant is zero, | 525 | // If the determinant is zero, |
526 | // then the inverse matrix is not unique. | 526 | // then the inverse matrix is not unique. |
527 | var det = RDGE.mat4._det4x4(m); | 527 | var det = RDGE.mat4._det4x4(m); |
528 | 528 | ||
@@ -580,7 +580,7 @@ RDGE.mat4.transformPoint = function (m, v) { | |||
580 | m[1] * x + m[5] * y + m[9] * z + m[13] * w, | 580 | m[1] * x + m[5] * y + m[9] * z + m[13] * w, |
581 | m[2] * x + m[6] * y + m[10] * z + m[14] * w, | 581 | m[2] * x + m[6] * y + m[10] * z + m[14] * w, |
582 | m[3] * x + m[7] * y + m[11] * z + m[15] * w]; | 582 | m[3] * x + m[7] * y + m[11] * z + m[15] * w]; |
583 | // 12 adds, 16 multiplies, 16 lookups. | 583 | // 12 adds, 16 multiplies, 16 lookups. |
584 | }; | 584 | }; |
585 | 585 | ||
586 | /** | 586 | /** |
@@ -589,7 +589,7 @@ RDGE.mat4.transformPoint = function (m, v) { | |||
589 | RDGE.mat4.transformVector = function (m, v) { | 589 | RDGE.mat4.transformVector = function (m, v) { |
590 | m = RDGE.mat4.inverse(m); | 590 | m = RDGE.mat4.inverse(m); |
591 | var x = v[0], y = v[1], z = v[2], w = v.length >= 4 ? v[3] : 0.0; | 591 | var x = v[0], y = v[1], z = v[2], w = v.length >= 4 ? v[3] : 0.0; |
592 | // 12 adds, 16 multiplies, 16 lookups. | 592 | // 12 adds, 16 multiplies, 16 lookups. |
593 | // transpose multiply | 593 | // transpose multiply |
594 | return [m[0] * x + m[1] * y + m[2] * z + m[3] * w, | 594 | return [m[0] * x + m[1] * y + m[2] * z + m[3] * w, |
595 | m[4] * x + m[5] * y + m[6] * z + m[7] * w, | 595 | m[4] * x + m[5] * y + m[6] * z + m[7] * w, |