diff options
author | Ananya Sen | 2012-07-09 16:52:49 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-09 16:52:49 -0700 |
commit | 2eb84584f44b8c774479d1af2ee1d810597474cf (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/helper-classes/RDGE/src/core/script/math | |
parent | bf9dba001ec84243e2f12cd13b0c0ae020fba4a2 (diff) | |
parent | cee0deca695359ab468bd06d0e05ed3b2010b338 (diff) | |
download | ninja-2eb84584f44b8c774479d1af2ee1d810597474cf.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into codemirror-custom-theme-removal
Conflicts:
js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/mat4.js | 1539 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/quat.js | 501 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec2.js | 433 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec3.js | 749 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec4.js | 567 |
5 files changed, 1897 insertions, 1892 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..fb95ee21 100755 --- a/js/helper-classes/RDGE/src/core/script/math/mat4.js +++ b/js/helper-classes/RDGE/src/core/script/math/mat4.js | |||
@@ -1,769 +1,770 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | |
5 | 5 | Redistribution and use in source and binary forms, with or without | |
6 | Redistribution and use in source and binary forms, with or without | 6 | modification, are permitted provided that the following conditions are met: |
7 | modification, are permitted provided that the following conditions are met: | 7 | |
8 | 8 | * Redistributions of source code must retain the above copyright notice, | |
9 | - Redistributions of source code must retain the above copyright notice, | 9 | this list of conditions and the following disclaimer. |
10 | this list of conditions and the following disclaimer. | 10 | |
11 | - Redistributions in binary form must reproduce the above copyright | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
12 | notice, this list of conditions and the following disclaimer in the | 12 | this list of conditions and the following disclaimer in the documentation |
13 | documentation and/or other materials provided with the distribution. | 13 | and/or other materials provided with the distribution. |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 14 | |
15 | may be used to endorse or promote products derived from this software | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | without specific prior written permission. | 16 | contributors may be used to endorse or promote products derived from this |
17 | 17 | software without specific prior written permission. | |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | </copyright> */ | 29 | POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | </copyright> */ | |
31 | /** | 31 | |
32 | * This library contains functions for operating on 4x4 matrices. Any JS array | 32 | /** |
33 | * containing at least 16 numeric components can represent a 4x4 matrix. | 33 | * This library contains functions for operating on 4x4 matrices. Any JS array |
34 | * | 34 | * containing at least 16 numeric components can represent a 4x4 matrix. |
35 | * For example, all of these are valid matrix construction methods: | 35 | * |
36 | * ... | 36 | * For example, all of these are valid matrix construction methods: |
37 | * var a = mat4.identity(); | 37 | * ... |
38 | * var b = mat4.perspective(90, aspectRatio, 0.1, 100.00); | 38 | * var a = mat4.identity(); |
39 | * var c = mat4.lookAt( [0, 0, 0], [1, 0, 0], [ 0, 1, 0 ] ); | 39 | * var b = mat4.perspective(90, aspectRatio, 0.1, 100.00); |
40 | * var d = mat4.basis( [1, 0, 0], [0, 1, 0], [ 0, 0, 1 ] ); | 40 | * var c = mat4.lookAt( [0, 0, 0], [1, 0, 0], [ 0, 1, 0 ] ); |
41 | * | 41 | * var d = mat4.basis( [1, 0, 0], [0, 1, 0], [ 0, 0, 1 ] ); |
42 | * This library is implemented assuming components are arranged | 42 | * |
43 | * contiguously in memory as such: | 43 | * This library is implemented assuming components are arranged |
44 | * M = [ x0, x1, x2, x3, | 44 | * contiguously in memory as such: |
45 | * y0, y1, y2, y3, | 45 | * M = [ x0, x1, x2, x3, |
46 | * z0, z1, z2, z3, | 46 | * y0, y1, y2, y3, |
47 | * w0, w1, w2, w3 ]; | 47 | * z0, z1, z2, z3, |
48 | * The translation components of a transformation matrix would be stored in | 48 | * w0, w1, w2, w3 ]; |
49 | * w0, w1, w2, or at indices 12, 13, and 14 of the array, as is consistent | 49 | * The translation components of a transformation matrix would be stored in |
50 | * with OpenGL. | 50 | * w0, w1, w2, or at indices 12, 13, and 14 of the array, as is consistent |
51 | */ | 51 | * with OpenGL. |
52 | // RDGE namespaces | 52 | */ |
53 | var RDGE = RDGE || {}; | 53 | // RDGE namespaces |
54 | RDGE.mat4 = {}; | 54 | var RDGE = RDGE || {}; |
55 | 55 | RDGE.mat4 = {}; | |
56 | /** | 56 | |
57 | * RDGE.mat4.string | 57 | /** |
58 | */ | 58 | * RDGE.mat4.string |
59 | RDGE.mat4.string = function (m) { | 59 | */ |
60 | var out = "{ "; | 60 | RDGE.mat4.string = function (m) { |
61 | out += m[0] + ", " + m[1] + ", " + m[2] + ", " + m[3] + ", "; | 61 | var out = "{ "; |
62 | out += m[4] + ", " + m[5] + ", " + m[6] + ", " + m[7] + ", "; | 62 | out += m[0] + ", " + m[1] + ", " + m[2] + ", " + m[3] + ", "; |
63 | out += m[8] + ", " + m[9] + ", " + m[10] + ", " + m[11] + ", "; | 63 | out += m[4] + ", " + m[5] + ", " + m[6] + ", " + m[7] + ", "; |
64 | out += m[12] + ", " + m[13] + ", " + m[14] + ", " + m[15] + " }"; | 64 | out += m[8] + ", " + m[9] + ", " + m[10] + ", " + m[11] + ", "; |
65 | return out; | 65 | out += m[12] + ", " + m[13] + ", " + m[14] + ", " + m[15] + " }"; |
66 | }; | 66 | return out; |
67 | 67 | }; | |
68 | RDGE.mat4.toCSSString = function (m, conversionConstant) { | 68 | |
69 | var cc = 10.0; | 69 | RDGE.mat4.toCSSString = function (m, conversionConstant) { |
70 | 70 | var cc = 10.0; | |
71 | if (conversionConstant) | 71 | |
72 | cc = conversionConstant; | 72 | if (conversionConstant) |
73 | 73 | cc = conversionConstant; | |
74 | var out = "matrix3d("; | 74 | |
75 | out += m[0].toFixed(10) + ", " + m[1].toFixed(10) + ", " + m[2].toFixed(10) + ", " + m[3].toFixed(10) + ", "; | 75 | var out = "matrix3d("; |
76 | out += m[4].toFixed(10) + ", " + m[5].toFixed(10) + ", " + m[6].toFixed(10) + ", " + m[7].toFixed(10) + ", "; | 76 | out += m[0].toFixed(10) + ", " + m[1].toFixed(10) + ", " + m[2].toFixed(10) + ", " + m[3].toFixed(10) + ", "; |
77 | out += m[8].toFixed(10) + ", " + m[9].toFixed(10) + ", " + m[10].toFixed(10) + ", " + m[11].toFixed(10) + ", "; | 77 | out += m[4].toFixed(10) + ", " + m[5].toFixed(10) + ", " + m[6].toFixed(10) + ", " + m[7].toFixed(10) + ", "; |
78 | out += m[12].toFixed(10) * cc + ", " + (600 - m[13].toFixed(10) * cc) + ", " + m[14].toFixed(10) * cc + ", " + m[15].toFixed(10) + ")"; | 78 | out += m[8].toFixed(10) + ", " + m[9].toFixed(10) + ", " + m[10].toFixed(10) + ", " + m[11].toFixed(10) + ", "; |
79 | return out; | 79 | out += m[12].toFixed(10) * cc + ", " + (600 - m[13].toFixed(10) * cc) + ", " + m[14].toFixed(10) * cc + ", " + m[15].toFixed(10) + ")"; |
80 | }; | 80 | return out; |
81 | 81 | }; | |
82 | /** | 82 | |
83 | * RDGE.mat4.verify | 83 | /** |
84 | * This function is provided for debugging purposes only. It is not recommended | 84 | * RDGE.mat4.verify |
85 | * to be used in performance critical areas of the code. | 85 | * This function is provided for debugging purposes only. It is not recommended |
86 | */ | 86 | * to be used in performance critical areas of the code. |
87 | RDGE.mat4.verify = function (m) { | 87 | */ |
88 | if (m == undefined || m.length == undefined || m.length < 16) { | 88 | RDGE.mat4.verify = function (m) { |
89 | return false; | 89 | if (m == undefined || m.length == undefined || m.length < 16) { |
90 | } | 90 | return false; |
91 | var i = 16; | 91 | } |
92 | while (i--) { | 92 | var i = 16; |
93 | if (typeof (m[i]) != "number") { | 93 | while (i--) { |
94 | return false; | 94 | if (typeof (m[i]) != "number") { |
95 | } | 95 | return false; |
96 | } | 96 | } |
97 | return true; | 97 | } |
98 | }; | 98 | return true; |
99 | 99 | }; | |
100 | /** | 100 | |
101 | * RDGE.mat4.copy | 101 | /** |
102 | */ | 102 | * RDGE.mat4.copy |
103 | RDGE.mat4.copy = function (m) { | 103 | */ |
104 | return [m[0], m[1], m[2], m[3], | 104 | RDGE.mat4.copy = function (m) { |
105 | m[4], m[5], m[6], m[7], | 105 | return [m[0], m[1], m[2], m[3], |
106 | m[8], m[9], m[10], m[11], | 106 | m[4], m[5], m[6], m[7], |
107 | m[12], m[13], m[14], m[15]]; | 107 | m[8], m[9], m[10], m[11], |
108 | }; | 108 | m[12], m[13], m[14], m[15]]; |
109 | 109 | }; | |
110 | /** | 110 | |
111 | * RDGE.mat4.inplace_copy | 111 | /** |
112 | */ | 112 | * RDGE.mat4.inplace_copy |
113 | RDGE.mat4.inplace_copy = function (dst, src) { | 113 | */ |
114 | dst[0] = src[0]; | 114 | RDGE.mat4.inplace_copy = function (dst, src) { |
115 | dst[1] = src[1]; | 115 | dst[0] = src[0]; |
116 | dst[2] = src[2]; | 116 | dst[1] = src[1]; |
117 | dst[3] = src[3]; | 117 | dst[2] = src[2]; |
118 | dst[4] = src[4]; | 118 | dst[3] = src[3]; |
119 | dst[5] = src[5]; | 119 | dst[4] = src[4]; |
120 | dst[6] = src[6]; | 120 | dst[5] = src[5]; |
121 | dst[7] = src[7]; | 121 | dst[6] = src[6]; |
122 | dst[8] = src[8]; | 122 | dst[7] = src[7]; |
123 | dst[9] = src[9]; | 123 | dst[8] = src[8]; |
124 | dst[10] = src[10]; | 124 | dst[9] = src[9]; |
125 | dst[11] = src[11]; | 125 | dst[10] = src[10]; |
126 | dst[12] = src[12]; | 126 | dst[11] = src[11]; |