aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/math/vec3.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/vec3.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/vec3.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/vec3.js748
1 files changed, 374 insertions, 374 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/math/vec3.js b/js/helper-classes/RDGE/src/core/script/math/vec3.js
index 86d17e04..7a47ffd2 100755
--- a/js/helper-classes/RDGE/src/core/script/math/vec3.js
+++ b/js/helper-classes/RDGE/src/core/script/math/vec3.js
@@ -1,374 +1,374 @@
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/** 32/**
33 * RDGE.vec3 = {} 33 * RDGE.vec3 = {}
34 * This library contains functions for operating on 3D vectors. Any JS array 34 * This library contains functions for operating on 3D vectors. Any JS array
35 * containing at least 3 numeric components can represent a 3D vector. 35 * containing at least 3 numeric components can represent a 3D vector.
36 * 36 *
37 * For example, all of these are valid RDGE.vec3 declarations: 37 * For example, all of these are valid RDGE.vec3 declarations:
38 * var a = [0, 0, 1]; 38 * var a = [0, 0, 1];
39 * var b = RDGE.vec3.zero(); 39 * var b = RDGE.vec3.zero();
40 * var c = RDGE.vec3.up(); 40 * var c = RDGE.vec3.up();
41 * 41 *
42 */ 42 */
43var RDGE = RDGE || {}; 43var RDGE = RDGE || {};
44RDGE.vec3 = {}; 44RDGE.vec3 = {};
45 45
46/** 46/**
47* RDGE.vec3.string 47* RDGE.vec3.string
48*/ 48*/
49RDGE.vec3.string = function (v) { 49RDGE.vec3.string = function (v) {
50 return "{ " + v[0] + ", " + v[1] + ", " + v[2] + " }"; 50 return "{ " + v[0] + ", " + v[1] + ", " + v[2] + " }";
51}; 51};
52 52
53/** 53/**
54 * RDGE.vec3.verify 54 * RDGE.vec3.verify
55 * This function is provided for debugging purposes only. It is not recommended 55 * This function is provided for debugging purposes only. It is not recommended
56 * to be used in performance critical areas of the code. 56 * to be used in performance critical areas of the code.
57 */ 57 */
58RDGE.vec3.verify = function (v) { 58RDGE.vec3.verify = function (v) {
59 if (v == undefined || v.length == undefined || v.length < 3) { 59 if (v == undefined || v.length == undefined || v.length < 3) {
60 return false; 60 return false;
61 } 61 }
62 if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number") { 62 if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number") {
63 return false; 63 return false;
64 } 64 }
65 return true; 65 return true;
66}; 66};
67 67
68/** 68/**
69* RDGE.vec3.inplace_copy 69* RDGE.vec3.inplace_copy
70*/ 70*/
71RDGE.vec3.inplace_copy = function (dst, src) { 71RDGE.vec3.inplace_copy = function (dst, src) {
72 dst[0] = src[0]; 72 dst[0] = src[0];
73 dst[1] = src[1]; 73 dst[1] = src[1];
74 dst[2] = src[2]; 74 dst[2] = src[2];
75}; 75};
76 76
77/** 77/**
78* RDGE.vec3.copy 78* RDGE.vec3.copy
79*/ 79*/
80RDGE.vec3.copy = function (v) { 80RDGE.vec3.copy = function (v) {
81 if (v.length == undefined) { 81 if (v.length == undefined) {
82 return [v, v, v]; 82 return [v, v, v];
83 } 83 }
84 84
85 return [v[0], v[1], v[2]]; 85 return [v[0], v[1], v[2]];
86}; 86};
87 87
88/** 88/**
89* RDGE.vec3.translation 89* RDGE.vec3.translation
90* description : returns a vector containing the translation vector of m. 90* description : returns a vector containing the translation vector of m.
91*/ 91*/
92RDGE.vec3.translation = function (m) { 92RDGE.vec3.translation = function (m) {
93 return [m[12], m[13], m[14]]; 93 return [m[12], m[13], m[14]];
94}; 94};
95 95
96/** 96/**
97* RDGE.vec3.basisX = function( m ) 97* RDGE.vec3.basisX = function( m )
98* description : returns a vector containing the translation vector of m. 98* description : returns a vector containing the translation vector of m.
99*/ 99*/
100RDGE.vec3.basisX = function (m) { 100RDGE.vec3.basisX = function (m) {
101 return [m[0], m[1], m[2]]; 101 return [m[0], m[1], m[2]];
102}; 102};
103 103
104/** 104/**
105* RDGE.vec3.basisY = function( m ) 105* RDGE.vec3.basisY = function( m )
106* description : returns a vector containing the translation vector of m. 106* description : returns a vector containing the translation vector of m.
107*/ 107*/
108RDGE.vec3.basisY = function (m) { 108RDGE.vec3.basisY = function (m) {
109 return [m[4], m[5], m[6]]; 109 return [m[4], m[5], m[6]];
110}; 110};
111 111
112/** 112/**
113* RDGE.vec3.basisZ = function( m ) 113* RDGE.vec3.basisZ = function( m )
114* description : returns a vector containing the translation vector of m. 114* description : returns a vector containing the translation vector of m.
115*/ 115*/
116RDGE.vec3.basisZ = function (m) { 116RDGE.vec3.basisZ = function (m) {
117 return [m[8], m[9], m[10]]; 117 return [m[8], m[9], m[10]];
118}; 118};
119 119
120/** 120/**
121* RDGE.vec3.zero 121* RDGE.vec3.zero
122*/ 122*/
123RDGE.vec3.zero = function () { 123RDGE.vec3.zero = function () {
124 return [0.0, 0.0, 0.0]; 124 return [0.0, 0.0, 0.0];
125}; 125};
126 126
127/** 127/**
128* RDGE.vec3.up 128* RDGE.vec3.up
129*/