aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/math
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/mat4.js49
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/quat.js29
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/vec2.js29
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/vec3.js45
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/vec4.js27
5 files changed, 92 insertions, 87 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..a0f47bcf 100755
--- a/js/helper-classes/RDGE/src/core/script/math/mat4.js
+++ b/js/helper-classes/RDGE/src/core/script/math/mat4.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -29,8 +30,8 @@ POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 30</copyright> */
30 31
31/** 32/**
32* This library contains functions for operating on 4x4 matrices. Any JS array 33* This library contains functions for operating on 4x4 matrices. Any JS array
33* containing at least 16 numeric components can represent a 4x4 matrix. 34* containing at least 16 numeric components can represent a 4x4 matrix.
34* 35*
35* For example, all of these are valid matrix construction methods: 36* For example, all of these are valid matrix construction methods:
36* ... 37* ...
@@ -39,15 +40,15 @@ POSSIBILITY OF SUCH DAMAGE.
39* var c = mat4.lookAt( [0, 0, 0], [1, 0, 0], [ 0, 1, 0 ] ); 40* 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 ] ); 41* var d = mat4.basis( [1, 0, 0], [0, 1, 0], [ 0, 0, 1 ] );
41* 42*
42* This library is implemented assuming components are arranged 43* This library is implemented assuming components are arranged
43* contiguously in memory as such: 44* contiguously in memory as such:
44* M = [ x0, x1, x2, x3, 45* M = [ x0, x1, x2, x3,
45* y0, y1, y2, y3, 46* y0, y1, y2, y3,
46* z0, z1, z2, z3, 47* z0, z1, z2, z3,
47* w0, w1, w2, w3 ]; 48* w0, w1, w2, w3 ];
48* The translation components of a transformation matrix would be stored in 49* 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 50* w0, w1, w2, or at indices 12, 13, and 14 of the array, as is consistent
50* with OpenGL. 51* with OpenGL.
51*/ 52*/
52// RDGE namespaces 53// RDGE namespaces
53var RDGE = RDGE || {}; 54var RDGE = RDGE || {};
@@ -81,7 +82,7 @@ RDGE.mat4.toCSSString = function (m, conversionConstant) {
81 82
82/** 83/**
83* RDGE.mat4.verify 84* RDGE.mat4.verify
84* This function is provided for debugging purposes only. It is not recommended 85* This function is provided for debugging purposes only. It is not recommended
85* to be used in performance critical areas of the code. 86* to be used in performance critical areas of the code.
86*/ 87*/
87RDGE.mat4.verify = function (m) { 88RDGE.mat4.verify = function (m) {
@@ -231,10 +232,10 @@ RDGE.mat4.angleAxis = function (angle, axis) {
231RDGE.mat4.lookAt = function (eye, at, up) { 232RDGE.mat4.lookAt = function (eye, at, up) {
232 /* 233 /*
233 var w_axis = new RDGE.vec3(posVec.x, posVec.y, posVec.z); 234 var w_axis = new RDGE.vec3(posVec.x, posVec.y, posVec.z);
234 235
235 var z_axis = subVec3(targetVec, w_axis); 236 var z_axis = subVec3(targetVec, w_axis);
236 z_axis.normalize(); 237 z_axis.normalize();
237 238
238 var x_axis = crossVec3(upVec, z_axis); 239 var x_axis = crossVec3(upVec, z_axis);
239 x_axis.normalize(); 240 x_axis.normalize();
240 241
@@ -522,7 +523,7 @@ RDGE.mat4._adjoint = function (m) {
522*/ 523*/
523RDGE.mat4.inverse = function (m) { 524RDGE.mat4.inverse = function (m) {
524 // Calculate the 4x4 determinant 525 // Calculate the 4x4 determinant
525 // If the determinant is zero, 526 // If the determinant is zero,
526 // then the inverse matrix is not unique. 527 // then the inverse matrix is not unique.
527 var det = RDGE.mat4._det4x4(m); 528 var det = RDGE.mat4._det4x4(m);
528 529
@@ -580,7 +581,7 @@ RDGE.mat4.transformPoint = function (m, v) {
580 m[1] * x + m[5] * y + m[9] * z + m[13] * w, 581 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, 582 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]; 583 m[3] * x + m[7] * y + m[11] * z + m[15] * w];
583 // 12 adds, 16 multiplies, 16 lookups. 584 // 12 adds, 16 multiplies, 16 lookups.
584}; 585};
585 586
586/** 587/**
@@ -589,7 +590,7 @@ RDGE.mat4.transformPoint = function (m, v) {
589RDGE.mat4.transformVector = function (m, v) { 590RDGE.mat4.transformVector = function (m, v) {
590 m = RDGE.mat4.inverse(m); 591 m = RDGE.mat4.inverse(m);
591 var x = v[0], y = v[1], z = v[2], w = v.length >= 4 ? v[3] : 0.0; 592 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. 593 // 12 adds, 16 multiplies, 16 lookups.
593 // transpose multiply 594 // transpose multiply
594 return [m[0] * x + m[1] * y + m[2] * z + m[3] * w, 595 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, 596 m[4] * x + m[5] * y + m[6] * z + m[7] * w,
diff --git a/js/helper-classes/RDGE/src/core/script/math/quat.js b/js/helper-classes/RDGE/src/core/script/math/quat.js
index a3812084..05b5ca48 100755
--- a/js/helper-classes/RDGE/src/core/script/math/quat.js
+++ b/js/helper-classes/RDGE/src/core/script/math/quat.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -33,9 +34,9 @@ POSSIBILITY OF SUCH DAMAGE.
33* RDGE.quat = {} 34* RDGE.quat = {}
34* This library contains utility functions for operating on quaternions. 35* This library contains utility functions for operating on quaternions.
35* -- 36* --
36* TODO: 37* TODO:
37* -need to add more helper functions for generating quaternions from 38* -need to add more helper functions for generating quaternions from
38* other representations (i.e. - eulers, angle-axis). 39* other representations (i.e. - eulers, angle-axis).
39*/ 40*/
40var RDGE = RDGE || {}; 41var RDGE = RDGE || {};
41RDGE.quat = {}; 42RDGE.quat = {};
diff --git a/js/helper-classes/RDGE/src/core/script/math/vec2.js b/js/helper-classes/RDGE/src/core/script/math/vec2.js
index 0a5b832d..ddc1be11 100755
--- a/js/helper-classes/RDGE/src/core/script/math/vec2.js
+++ b/js/helper-classes/RDGE/src/core/script/math/vec2.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved.