aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/math/vec3.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/vec3.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/vec3.js749
1 files changed, 375 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 c50df00c..da7c7cff 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,375 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License. 4
5 5Redistribution and use in source and binary forms, with or without
6Redistribution and use in source and binary forms, with or without 6modification, are permitted provided that the following conditions are met:
7modification, 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.
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28POSSIBILITY OF SUCH DAMAGE. 28ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29</copyright> */ 29POSSIBILITY OF SUCH DAMAGE.
30 30</copyright> */
31 31
32/** 32
33 * RDGE.vec3 = {} 33/**
34 * This library contains functions for operating on 3D vectors. Any JS array 34 * RDGE.vec3 = {}
35 * containing at least 3 numeric components can represent a 3D vector. 35 * This library contains functions for operating on 3D vectors. Any JS array
36 * 36 * containing at least 3 numeric components can represent a 3D vector.
37 * For example, all of these are valid RDGE.vec3 declarations: 37 *
38 * var a = [0, 0, 1]; 38 * For example, all of these are valid RDGE.vec3 declarations:
39 * var b = RDGE.vec3.zero(); 39 * var a = [0, 0, 1];
40 * var c = RDGE.vec3.up(); 40 * var b = RDGE.vec3.zero();
41 * 41 * var c = RDGE.vec3.up();
42 */ 42 *
43var RDGE = RDGE || {}; 43 */
44RDGE.vec3 = {}; 44var RDGE = RDGE || {};
45 45RDGE.vec3 = {};
46/** 46
47* RDGE.vec3.string 47/**
48*/ 48* RDGE.vec3.string
49RDGE.vec3.string = function (v) { 49*/
50 return "{ " + v[0] + ", " + v[1] + ", " + v[2] + " }"; 50RDGE.vec3.string = function (v) {
51}; 51 return "{ " + v[0] + ", " + v[1] + ", " + v[2] + " }";
52 52};
53/** 53
54 * RDGE.vec3.verify 54/**
55 * This function is provided for debugging purposes only. It is not recommended 55 * RDGE.vec3.verify
56 * to be used in performance critical areas of the code. 56 * This function is provided for debugging purposes only. It is not recommended
57 */ 57 * to be used in performance critical areas of the code.
58RDGE.vec3.verify = function (v) { 58 */
59 if (v == undefined || v.length == undefined || v.length < 3) { 59RDGE.vec3.verify = function (v) {
60 return false; 60 if (v == undefined || v.length == undefined || v.length < 3) {
61 } 61 return false;
62 if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number") { 62 }
63 return false; 63 if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number") {
64 } 64 return false;
65 return true; 65 }
66}; 66 return true;
67 67};
68/** 68
69* RDGE.vec3.inplace_copy 69/**
70*/ 70* RDGE.vec3.inplace_copy
71RDGE.vec3.inplace_copy = function (dst, src) { 71*/
72 dst[0] = src[0]; 72RDGE.vec3.inplace_copy = function (dst, src) {
73 dst[1] = src[1]; 73 dst[0] = src[0];
74 dst[2] = src[2]; 74 dst[1] = src[1];
75}; 75 dst[2] = src[2];
76 76};
77/** 77
78* RDGE.vec3.copy 78/**
79*/ 79* RDGE.vec3.copy
80RDGE.vec3.copy = function (v) { 80*/
81 if (v.length == undefined) { 81RDGE.vec3.copy = function (v) {
82 return [v, v, v]; 82 if (v.length == undefined) {
83 } 83 return [v, v, v];
84 84 }
85 return [v[0], v[1], v[2]]; 85
86}; 86 return [v[0], v[1], v[2]];
87 87};
88/** 88
89* RDGE.vec3.translation 89/**
90* description : returns a vector containing the translation vector of m. 90* RDGE.vec3.translation
91*/ 91* description : returns a vector containing the translation vector of m.
92RDGE.vec3.translation = function (m) { 92*/
93 return [m[12], m[13], m[14]]; 93RDGE.vec3.translation = function (m) {
94}; 94 return [m[12], m[13], m[14]];
95 95};
96/** 96
97* RDGE.vec3.basisX = function( m ) 97/**
98* description : returns a vector containing the translation vector of m. 98* RDGE.vec3.basisX = function( m )
99*/ 99* description : returns a vector containing the translation vector of m.
100RDGE.vec3.basisX = function (m) { 100*/
101 return [m[0], m[1], m[2]]; 101RDGE.vec3.basisX = function (m) {
102}; 102 return [m[0], m[1], m[2]];
103 103};
104/** 104
105* RDGE.vec3.basisY = function( m ) 105/**
106* description : returns a vector containing the translation vector of m. 106* RDGE.vec3.basisY = function( m )
107*/ 107* description : returns a vector containing the translation vector of m.
108RDGE.vec3.basisY = function (m) { 108*/
109 return [m[4], m[5], m[6]]; 109RDGE.vec3.basisY = function (m) {
110}; 110 return [m[4], m[5], m[6]];
111 111};
112/** 112
113* RDGE.vec3.basisZ = function( m ) 113/**
114* description : returns a vector containing the translation vector of m. 114* RDGE.vec3.basisZ = function( m )
115*/ 115* description : returns a vector containing the translation vector of m.
116RDGE.vec3.basisZ = function (m) { 116*/
117 return [m[8], m[9], m[10]]; 117RDGE.vec3.basisZ = function (m) {
118}; 118 return [m[8], m[9], m[10]];
119 119};
120/** 120
121* RDGE.vec3.zero 121/**
122*/ 122* RDGE.vec3.zero
123RDGE.vec3.zero = function () { 123*/
124 return [0.0, 0.0, 0.0]; 124RDGE.vec3.zero = function () {
125}; 125 return [0.0, 0.0, 0.0];
126 126};
127/** 127
128* RDGE.vec3.up 128/**
129*/ 129* RDGE.vec3.up
130RDGE.vec3.up = function () { 130*/
131 return [0.0, 1.0, 0.0]; 131RDGE.vec3.up = function () {
132}; 132 return [0.0, 1.0, 0.0];
133 133};
134/** 134
135* RDGE.vec3.forward 135/**
136*/ 136* RDGE.vec3.forward
137RDGE.vec3.forward = function () { 137*/
138 return [0.0, 0.0, 1.0]; 138RDGE.vec3.forward = function () {
139}; 139 return [0.0, 0.0, 1.0];
140