diff options
author | Ananya Sen | 2012-04-17 18:11:55 -0700 |
---|---|---|
committer | Ananya Sen | 2012-04-17 18:11:55 -0700 |
commit | 35abad196cc9feb76ef50c1b63032a38233a6d51 (patch) | |
tree | 914689c66d4ab6c6e088b571eade0a0e35082916 /js/helper-classes/RDGE/src/core/script/math/vec4.js | |
parent | 1f891c58bad0b7746659aa4138001b5ee76d9a0e (diff) | |
parent | 616a8532099fec2a15855eac97cd85cb60c4451c (diff) | |
download | ninja-35abad196cc9feb76ef50c1b63032a38233a6d51.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/vec4.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec4.js | 315 |
1 files changed, 158 insertions, 157 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 3a0de375..a655d006 100755 --- a/js/helper-classes/RDGE/src/core/script/math/vec4.js +++ b/js/helper-classes/RDGE/src/core/script/math/vec4.js | |||
@@ -5,254 +5,255 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * vec4 = {} | 8 | * RDGE.vec4 = {} |
9 | * This library contains functions for operating on 4D vectors. Any JS array | 9 | * This library contains functions for operating on 4D vectors. Any JS array |
10 | * containing at least 4 numeric components can represent a 4D vector. | 10 | * containing at least 4 numeric components can represent a 4D vector. |
11 | * | 11 | * |
12 | * For example, all of these are valid vec4 declarations: | 12 | * For example, all of these are valid RDGE.vec4 declarations: |
13 | * var a = [0, 0, 0, 1]; | 13 | * var a = [0, 0, 0, 1]; |
14 | * var b = vec3.identity(); | 14 | * var b = RDGE.RDGE.vec4.identity(); |
15 | * var c = vec3.zero(); | 15 | * var c = RDGE.RDGE.vec4.zero(); |
16 | * | 16 | * |
17 | */ | 17 | */ |
18 | vec4 = {}; | 18 | var RDGE = RDGE || {}; |
19 | RDGE.vec4 = {}; | ||
19 | 20 | ||
20 | /** | 21 | /** |
21 | * vec4.string | 22 | * RDGE.vec4.string |
22 | */ | 23 | */ |
23 | vec4.string = function(v) { | 24 | RDGE.vec4.string = function (v) { |
24 | return "{ " + v[0] + ", " + v[1] + ", " + v[2] + ", " + v[3] + " }"; | 25 | return "{ " + v[0] + ", " + v[1] + ", " + v[2] + ", " + v[3] + " }"; |
25 | } | 26 | }; |
26 | 27 | ||
27 | /** | 28 | /** |
28 | * vec4.verify | 29 | * RDGE.vec4.verify |
29 | */ | 30 | */ |
30 | vec4.verify = function(v) { | 31 | RDGE.vec4.verify = function (v) { |
31 | if (v == undefined || v.length == undefined || v.length < 4) { | 32 | if (v == undefined || v.length == undefined || v.length < 4) { |
32 | return false; | 33 | return false; |
33 | } | 34 | } |
34 | 35 | ||
35 | if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number" || typeof (v[3]) != "number") { | 36 | if (typeof (v[0]) != "number" || typeof (v[1]) != "number" || typeof (v[2]) != "number" || typeof (v[3]) != "number") { |
36 | return false; | 37 | return false; |
37 | } | 38 | } |
38 | 39 | ||
39 | return true; | 40 | return true; |
40 | } | 41 | }; |
41 | 42 | ||
42 | /** | 43 | /** |
43 | * vec4.inplace_copy | 44 | * RDGE.vec4.inplace_copy |
44 | */ | 45 | */ |
45 | vec4.inplace_copy = function(dst, src) { | 46 | RDGE.vec4.inplace_copy = function (dst, src) { |
46 | dst[0] = src[0]; | 47 | dst[0] = src[0]; |
47 | dst[1] = src[1]; | 48 | dst[1] = src[1]; |
48 | dst[2] = src[2]; | 49 | dst[2] = src[2]; |
49 | dst[3] = src[3]; | 50 | dst[3] = src[3]; |
50 | } | 51 | }; |
51 | 52 | ||
52 | /** | 53 | /** |
53 | * vec4.copy | 54 | * RDGE.vec4.copy |
54 | */ | 55 | */ |
55 | vec4.copy = function(v) { | 56 | RDGE.vec4.copy = function (v) { |
56 | if( v.length == undefined ) { | 57 | if (v.length == undefined) { |
57 | return [ v, v, v, v ]; | 58 | return [v, v, v, v]; |
58 | } | 59 | } |
59 | 60 | ||
60 | if( v.length == 3 ) { | 61 | if (v.length == 3) { |
61 | return [ v[0], v[1], v[2], 1.0 ]; | 62 | return [v[0], v[1], v[2], 1.0]; |
62 | } | 63 | } |
63 | 64 | ||
64 | return [ v[0], v[1], v[2], v[3] ]; | 65 | return [v[0], v[1], v[2], v[3]]; |
65 | } | 66 | }; |
66 | 67 | ||
67 | /** | 68 | /** |
68 | * vec4.zero | 69 | * RDGE.vec4.zero |
69 | */ | 70 | */ |
70 | vec4.zero = function() { | 71 | RDGE.vec4.zero = function () { |
71 | return [ 0.0, 0.0, 0.0, 0.0 ]; | 72 | return [0.0, 0.0, 0.0, 0.0]; |
72 | } | 73 | }; |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * vec4.identity | 76 | * RDGE.vec4.identity |
76 | */ | 77 | */ |
77 | vec4.identity = function() { | 78 | RDGE.vec4.identity = function () { |
78 | return [ 0.0, 0.0, 0.0, 1.0 ]; | 79 | return [0.0, 0.0, 0.0, 1.0]; |
79 | } | 80 | }; |
80 | 81 | ||
81 | /** | 82 | /** |
82 | * vec4.up | 83 | * RDGE.vec4.up |
83 | */ | 84 | */ |
84 | vec4.up = function() { | 85 | RDGE.vec4.up = function () { |
85 | return [ 0.0, 1.0, 0.0, 0.0 ]; | 86 | return [0.0, 1.0, 0.0, 0.0]; |
86 | } | 87 | }; |
87 | 88 | ||
88 | /** | 89 | /** |
89 | * vec4.forward | 90 | * RDGE.vec4.forward |
90 | */ | 91 | */ |
91 | vec4.forward = function() { | 92 | RDGE.vec4.forward = function () { |
92 | return [ 0.0, 0.0, 1.0, 0.0 ]; | 93 | return [0.0, 0.0, 1.0, 0.0]; |
93 | } | 94 | }; |
94 | 95 | ||
95 | /** | 96 | /** |
96 | * vec4.right | 97 | * RDGE.vec4.right |
97 | */ | 98 | */ |
98 | vec4.right = function() { | 99 | RDGE.vec4.right = function () { |
99 | return [ 1.0, 0.0, 0.0, 0.0 ]; | 100 | return [1.0, 0.0, 0.0, 0.0]; |
100 | } | 101 | }; |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * vec4.random | 104 | * RDGE.vec4.random |
104 | */ | 105 | */ |
105 | vec4.random = function(min, max) { | 106 | RDGE.vec4.random = function (min, max) { |
106 | return [ min[0] + (max[0] - min[0]) * Math.random(), | 107 | return [min[0] + (max[0] - min[0]) * Math.random(), |
107 | min[1] + (max[1] - min[1]) * Math.random(), | 108 | min[1] + (max[1] - min[1]) * Math.random(), |
108 | min[2] + (max[2] - min[2]) * Math.random(), | 109 | min[2] + (max[2] - min[2]) * Math.random(), |
109 | min[3] + (max[3] - min[3]) * Math.random()]; | 110 | min[3] + (max[3] - min[3]) * Math.random()]; |
110 | } | 111 | }; |
111 | 112 | ||
112 | /** | 113 | /** |
113 | * vec4.add | 114 | * RDGE.vec4.add |
114 | */ | 115 | */ |
115 | vec4.add = function(a, b) { | 116 | RDGE.vec4.add = function (a, b) { |
116 | return [ a[0] + b[0], | 117 | return [a[0] + b[0], |
117 | a[1] + b[1], | 118 | a[1] + b[1], |
118 | a[2] + b[2], | 119 | a[2] + b[2], |
119 | a[3] + b[3] ]; | 120 | a[3] + b[3]]; |
120 | } | 121 | }; |
121 | 122 | ||
122 | /** | 123 | /** |
123 | * vec4.sub | 124 | * RDGE.vec4.sub |
124 | */ | 125 | */ |
125 | vec4.sub = function(a, b) { | 126 | RDGE.vec4.sub = function (a, b) { |
126 | return [ a[0] - b[0], | 127 | return [a[0] - b[0], |
127 | a[1] - b[1], | 128 | a[1] - b[1], |
128 | a[2] - b[2], | 129 | a[2] - b[2], |
129 | a[3] - b[3] ]; | 130 | a[3] - b[3]]; |
130 | } | 131 | }; |
131 | 132 | ||
132 | /** | 133 | /** |
133 | * vec4.mul | 134 | * RDGE.vec4.mul |
134 | */ | 135 | */ |
135 | vec4.mul = function(a, b) { | 136 | RDGE.vec4.mul = function (a, b) { |
136 | return [ a[0] * b[0], |