diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/vec3.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec3.js | 748 |
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 c50df00c..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> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | BSD License. |
5 | 5 | ||
6 | Redistribution and use in source and binary forms, with or without | 6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 7 | modification, 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 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | POSSIBILITY 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 | */ |
43 | var RDGE = RDGE || {}; | 43 | var RDGE = RDGE || {}; |
44 | RDGE.vec3 = {}; | 44 | RDGE.vec3 = {}; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * RDGE.vec3.string | 47 | * RDGE.vec3.string |
48 | */ | 48 | */ |
49 | RDGE.vec3.string = function (v) { | 49 | RDGE.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 | */ |
58 | RDGE.vec3.verify = function (v) { | 58 | RDGE.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 | */ |
71 | RDGE.vec3.inplace_copy = function (dst, src) { | 71 | RDGE.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 | */ |
80 | RDGE.vec3.copy = function (v) { | 80 | RDGE.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 | */ |
92 | RDGE.vec3.translation = function (m) { | 92 | RDGE.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 | */ |
100 | RDGE.vec3.basisX = function (m) { | 100 | RDGE.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 | */ |
108 | RDGE.vec3.basisY = function (m) { | 108 | RDGE.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 | */ |
116 | RDGE.vec3.basisZ = function (m) { | 116 | RDGE.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 | */ |
123 | RDGE.vec3.zero = function () { | 123 | RDGE.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 | */ | 129 | */ |
130 | RDGE.vec3.up = function () { | 130 | RDGE.vec3.up = function () { |