aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/math/mat4.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 12:34:53 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit3644cb6def4f681c99959e5729e78ea353441fad (patch)
treef8a886f4829e507cc4956db37cff2580cae6003d /js/helper-classes/RDGE/src/core/script/math/mat4.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/mat4.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/mat4.js1538
1 files changed, 769 insertions, 769 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 d5cd7039..d4d8e89d 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,769 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility, Inc
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4BSD License.
5 5
6Redistribution and use in source and binary forms, with or without 6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 7modification, are permitted provided that the following conditions are met:
8 8
9 - Redistributions of source code must retain the above copyright notice, 9 - Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 10 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the 12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution. 13 documentation and/or other materials provided with the distribution.
14 - Neither the name of Motorola Mobility nor the names of its contributors 14 - Neither the name of Motorola Mobility nor the names of its contributors
15 may be used to endorse or promote products derived from this software 15 may be used to endorse or promote products derived from this software
16 without specific prior written permission. 16 without specific prior written permission.
17 17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY 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* ...
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
53var RDGE = RDGE || {}; 53var RDGE = RDGE || {};
54RDGE.mat4 = {}; 54RDGE.mat4 = {};
55 55
56/** 56/**
57* RDGE.mat4.string 57* RDGE.mat4.string
58*/ 58*/
59RDGE.mat4.string = function (m) { 59RDGE.mat4.string = function (m) {
60 var out = "{ "; 60 var out = "{ ";
61 out += m[0] + ", " + m[1] + ", " + m[2] + ", " + m[3] + ", "; 61 out += m[0] + ", " + m[1] + ", " + m[2] + ", " + m[3] + ", ";
62 out += m[4] + ", " + m[5] + ", " + m[6] + ", " + m[7] + ", "; 62 out += m[4] + ", " + m[5] + ", " + m[6] + ", " + m[7] + ", ";
63 out += m[8] + ", " + m[9] + ", " + m[10] + ", " + m[11] + ", "; 63 out += m[8] + ", " + m[9] + ", " + m[10] + ", " + m[11] + ", ";
64 out += m[12] + ", " + m[13] + ", " + m[14] + ", " + m[15] + " }"; 64 out += m[12] + ", " + m[13] + ", " + m[14] + ", " + m[15] + " }";
65 return out; 65 return out;
66}; 66};
67 67
68RDGE.mat4.toCSSString = function (m, conversionConstant) { 68RDGE.mat4.toCSSString = function (m, conversionConstant) {
69 var cc = 10.0; 69 var cc = 10.0;
70 70
71 if (conversionConstant) 71 if (conversionConstant)
72 cc = conversionConstant; 72 cc = conversionConstant;
73 73
74 var out = "matrix3d("; 74 var out = "matrix3d(";
75 out += m[0].toFixed(10) + ", " + m[1].toFixed(10) + ", " + m[2].toFixed(10) + ", " + m[3].toFixed(10) + ", "; 75 out += m[0].toFixed(10) + ", " + m[1].toFixed(10) + ", " + m[2].toFixed(10) + ", " + m[3].toFixed(10) + ", ";
76 out += m[4].toFixed(10) + ", " + m[5].toFixed(10) + ", " + m[6].toFixed(10) + ", " + m[7].toFixed(10) + ", "; 76 out += m[4].toFixed(10) + ", " + m[5].toFixed(10) + ", " + m[6].toFixed(10) + ", " + m[7].toFixed(10) + ", ";
77 out += m[8].toFixed(10) + ", " + m[9].toFixed(10) + ", " + m[10].toFixed(10) + ", " + m[11].toFixed(10) + ", "; 77 out += m[8].toFixed(10) + ", " + m[9].toFixed(10) + ", " + m[10].toFixed(10) + ", " + m[11].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[12].toFixed(10) * cc + ", " + (600 - m[13].toFixed(10) * cc) + ", " + m[14].toFixed(10) * cc + ", " + m[15].toFixed(10) + ")";
79 return out; 79 return out;
80}; 80};
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*/
87RDGE.mat4.verify = function (m) { 87RDGE.mat4.verify = function (m) {
88 if (m == undefined || m.length == undefined || m.length < 16) { 88 if (m == undefined || m.length == undefined || m.length < 16) {
89 return false; 89 return false;
90 } 90 }
91 var i = 16; 91 var i = 16;
92 while (i--) { 92 while (i--) {
93 if (typeof (m[i]) != "number") { 93 if (typeof (m[i]) != "number") {
94 return false; 94 return false;
95 } 95 }
96 } 96 }
97 return true; 97 return true;
98}; 98};
99 99
100/** 100/**
101* RDGE.mat4.copy 101* RDGE.mat4.copy
102*/ 102*/
103RDGE.mat4.copy = function (m) { 103RDGE.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/**
111* RDGE.mat4.inplace_copy 111* RDGE.mat4.inplace_copy
112*/ 112*/
113RDGE.mat4.inplace_copy = function (dst, src) { 113RDGE.mat4.inplace_copy = function (dst, src) {
114 dst[0] = src[0]; 114 dst[0] = src[0];
115 dst[1] = src[1]; 115 dst[1] = src[1];
116 dst[2] = src[2]; 116 dst[2] = src[2];
117 dst[3] = src[3]; 117 dst[3] = src[3];
118 dst[4] = src[4]; 118 dst[4] = src[4];
119 dst[5] = src[5]; 119 dst[5] = src[5];
120 dst[6] = src[6]; 120 dst[6] = src[6];
121 dst[7] = src[7]; 121 dst[7] = src[7];
122 dst[8] = src[8]; 122 dst[8] = src[8];
123 dst[9] = src[9]; 123 dst[9] = src[9];
124 dst[10] = src[10]; 124 dst[10] = src[10];