aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/math/vec4.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/vec4.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/vec4.js566
1 files changed, 283 insertions, 283 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/math/vec4.js b/js/helper-classes/RDGE/src/core/script/math/vec4.js
index 53759d6e..afc05251 100755
--- a/js/helper-classes/RDGE/src/core/script/math/vec4.js
+++ b/js/helper-classes/RDGE/src/core/script/math/vec4.js
@@ -1,283 +1,283 @@
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* RDGE.vec4 = {} 32* RDGE.vec4 = {}
33* This library contains functions for operating on 4D vectors. Any JS array 33* This library contains functions for operating on 4D vectors. Any JS array
34* containing at least 4 numeric components can represent a 4D vector. 34* containing at least 4 numeric components can represent a 4D vector.
35* 35*
36* For example, all of these are valid RDGE.vec4 declarations: 36* For example, all of these are valid RDGE.vec4 declarations:
37* var a = [0, 0, 0, 1]; 37* var a = [0, 0, 0, 1];
38* var b = RDGE.RDGE.vec4.identity(); 38* var b = RDGE.RDGE.vec4.identity();
39* var c = RDGE.RDGE.vec4.zero(); 39* var c = RDGE.RDGE.vec4.zero();
40* 40*
41*/ 41*/
42var RDGE = RDGE || {}; 42var RDGE = RDGE || {};
43RDGE.vec4 = {}; 43RDGE.vec4 = {};
44 44
45/** 45/**
46* RDGE.vec4.string 46* RDGE.vec4.string
47*/ 47*/
48RDGE.vec4.string = function (v) { 48RDGE.vec4.string = function (v) {
49 return "{ " + v[0] + ", " + v[1] + ", " + v[2] + ", " + v[3] + " }"; 49 return "{ " + v[0] + ", " + v[1] + ", " + v[2] + ", " + v[3] + " }";
50}; 50};
51 51
52/** 52/**
53* RDGE.vec4.verify 53* RDGE.vec4.verify
54*/ 54*/
55RDGE.vec4.verify = function (v) { 55RDGE.vec4.verify = function (v) {
56 if (v == undefined || v.length == undefined || v.length < 4) { 56 if (v == undefined || v.length == undefined || v.length < 4) {
57 return false; 57 return false;
58 } 58 }
59 59
60 if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number" || typeof (v[3]) != "number") { 60 if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number" || typeof (v[3]) != "number") {
61 return false; 61 return false;
62 } 62 }
63 63
64 return true; 64 return true;
65}; 65};
66 66
67/** 67/**
68* RDGE.vec4.inplace_copy 68* RDGE.vec4.inplace_copy
69*/ 69*/
70RDGE.vec4.inplace_copy = function (dst, src) { 70RDGE.vec4.inplace_copy = function (dst, src) {
71 dst[0] = src[0]; 71 dst[0] = src[0];
72 dst[1] = src[1]; 72 dst[1] = src[1];
73 dst[2] = src[2]; 73 dst[2] = src[2];
74 dst[3] = src[3]; 74 dst[3] = src[3];
75}; 75};
76 76
77/** 77/**
78* RDGE.vec4.copy 78* RDGE.vec4.copy
79*/ 79*/
80RDGE.vec4.copy = function (v) { 80RDGE.vec4.copy = function (v) {
81 if (v.length == undefined) { 81 if (v.length == undefined) {
82 return [v, v, v, v]; 82 return [v, v, v, v];
83 } 83 }
84 84
85 if (v.length == 3) { 85 if (v.length == 3) {
86 return [v[0], v[1], v[2], 1.0]; 86 return [v[0], v[1], v[2], 1.0];
87 } 87 }
88 88
89 return [v[0], v[1], v[2], v[3]]; 89 return [v[0], v[1], v[2], v[3]];
90}; 90};
91 91
92/** 92/**
93* RDGE.vec4.zero 93* RDGE.vec4.zero
94*/ 94*/
95RDGE.vec4.zero = function () { 95RDGE.vec4.zero = function () {
96 return [0.0, 0.0, 0.0, 0.0]; 96 return [0.0, 0.0, 0.0, 0.0];
97}; 97};
98 98
99/** 99/**
100* RDGE.vec4.identity 100* RDGE.vec4.identity
101*/ 101*/
102RDGE.vec4.identity = function () { 102RDGE.vec4.identity = function () {
103 return [0.0, 0.0, 0.0, 1.0]; 103 return [0.0, 0.0, 0.0, 1.0];
104}; 104};
105 105
106/** 106/**
107* RDGE.vec4.up 107* RDGE.vec4.up
108*/ 108*/
109RDGE.vec4.up = function () { 109RDGE.vec4.up = function () {
110 return [0.0, 1.0, 0.0, 0.0]; 110 return [0.0, 1.0, 0.0, 0.0];
111}; 111};
112 112
113/** 113/**
114* RDGE.vec4.forward 114* RDGE.vec4.forward
115*/ 115*/
116RDGE.vec4.forward = function () { 116RDGE.vec4.forward = function () {
117 return [0.0, 0.0, 1.0, 0.0]; 117 return [0.0, 0.0, 1.0, 0.0];
118}; 118};
119 119
120/** 120/**
121* RDGE.vec4.right 121* RDGE.vec4.right
122*/ 122*/
123RDGE.vec4.right = function () { 123RDGE.vec4.right = function () {
124 return [1.0, 0.0, 0.0, 0.0]; 124 return [1.0, 0.0, 0.0, 0.0];
125}; 125};
126 126
127/** 127/**
128* RDGE.vec4.random 128* RDGE.vec4.random
129*/ 129*/
130RDGE.vec4.random = function (min, max) { 130RDGE.vec4.random = function (min, max) {
131 return [min[0] + (max[0] - min[0]) * Math.random(), 131 return [min[0] + (max[0] - min[0]) * Math.random(),
132 min[1] + (max[1] - min[1]) * Math.random(), 132 min[1] + (max[1] - min[1]) * Math.random(),
133 min[2] + (max[2] - min[2]) * Math.random(), 133 min[2] + (max[2] - min[2]) * Math.random(),