diff options
author | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
---|---|---|
committer | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
commit | 53051672a62208fbc96957719d8285fac6431ed6 (patch) | |
tree | 79d542ee811044e8af2ef84aa0d6662c6eb895c4 /js/helper-classes/RDGE/src/core/script/math/vec2.js | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | 5146f224258929415adf4a8022e492454b4e2476 (diff) | |
download | ninja-53051672a62208fbc96957719d8285fac6431ed6.tar.gz |
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Conflicts:
js/panels/Timeline/DragDrop.js
js/panels/Timeline/Keyframe.reel/Keyframe.js
js/panels/Timeline/Layer.reel/Layer.js
js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
js/panels/Timeline/Span.reel/Span.js
js/panels/Timeline/Style.reel/Style.js
js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
js/panels/Timeline/Track.reel/Track.html
js/panels/Timeline/Track.reel/Track.js
js/panels/Timeline/Track.reel/css/Track.css
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.html
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.js
js/panels/Timeline/TrackSpacer.reel/css/TrackSpacer.css
js/panels/Timeline/Tween.reel/Tween.js
Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/vec2.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/math/vec2.js | 433 |
1 files changed, 217 insertions, 216 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/math/vec2.js b/js/helper-classes/RDGE/src/core/script/math/vec2.js index 0a5b832d..4bab755f 100755 --- a/js/helper-classes/RDGE/src/core/script/math/vec2.js +++ b/js/helper-classes/RDGE/src/core/script/math/vec2.js | |||
@@ -1,216 +1,217 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | |
5 | 5 | Redistribution and use in source and binary forms, with or without | |
6 | Redistribution and use in source and binary forms, with or without | 6 | modification, are permitted provided that the following conditions are met: |
7 | modification, 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. | |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | </copyright> */ | 29 | POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | </copyright> */ | |
31 | 31 | ||
32 | /** | 32 | |
33 | * RDGE.vec2 = {} | 33 | /** |
34 | * This library contains functions for operating on 2D vectors. | 34 | * RDGE.vec2 = {} |
35 | * A 2D vector can be any array containing at least 2 numeric components. | 35 | * This library contains functions for operating on 2D vectors. |
36 | * All of the following are valid methods for declaring a RDGE.vec2: | 36 | * A 2D vector can be any array containing at least 2 numeric components. |
37 | * var a = [0, 1]; | 37 | * All of the following are valid methods for declaring a RDGE.vec2: |
38 | * var b = RDGE.vec2.zero(); | 38 | * var a = [0, 1]; |
39 | * var c = RDGE.vec2.up(); | 39 | * var b = RDGE.vec2.zero(); |
40 | */ | 40 | * var c = RDGE.vec2.up(); |
41 | var RDGE = RDGE || {}; | 41 | */ |
42 | RDGE.vec2 = {}; | 42 | var RDGE = RDGE || {}; |
43 | 43 | RDGE.vec2 = {}; | |
44 | /** | 44 | |
45 | * RDGE.vec2.string | 45 | /** |
46 | */ | 46 | * RDGE.vec2.string |
47 | RDGE.vec2.string = function (v) { | 47 | */ |
48 | return "{ " + v[0] + ", " + v[1] + " }"; | 48 | RDGE.vec2.string = function (v) { |
49 | }; | 49 | return "{ " + v[0] + ", " + v[1] + " }"; |
50 | 50 | }; | |
51 | /** | 51 | |
52 | * RDGE.vec2.verify | 52 | /** |
53 | * This function is provided for debugging purposes only. It is not recommended | 53 | * RDGE.vec2.verify |
54 | * to be used in performance critical areas of the code. | 54 | * This function is provided for debugging purposes only. It is not recommended |
55 | */ | 55 | * to be used in performance critical areas of the code. |
56 | RDGE.vec2.verify = function (v) { | 56 | */ |
57 | if (v == undefined || v.length == undefined || v.length < 2) { | 57 | RDGE.vec2.verify = function (v) { |
58 | return false; | 58 | if (v == undefined || v.length == undefined || v.length < 2) { |
59 | } | 59 | return false; |
60 | 60 | } | |
61 | if (typeof (v[0]) != "number" || typeof (v[1]) != "number") { | 61 | |
62 | return false; | 62 | if (typeof (v[0]) != "number" || typeof (v[1]) != "number") { |
63 | } | 63 | return false; |
64 | 64 | } | |
65 | return true; | 65 | |
66 | }; | 66 | return true; |
67 | 67 | }; | |
68 | /** | 68 | |
69 | * RDGE.vec2.copy | 69 | /** |
70 | */ | 70 | * RDGE.vec2.copy |
71 | RDGE.vec2.copy = function (v) { | 71 | */ |
72 | if (v.length == undefined) { | 72 | RDGE.vec2.copy = function (v) { |
73 | return [v, v]; | 73 | if (v.length == undefined) { |
74 | } | 74 | return [v, v]; |
75 | 75 | } | |
76 | return [v[0], v[1]]; | 76 | |
77 | }; | 77 | return [v[0], v[1]]; |
78 | 78 | }; | |
79 | /** | 79 | |
80 | * RDGE.vec2.inplace_copy | 80 | /** |
81 | */ | 81 | * RDGE.vec2.inplace_copy |
82 | RDGE.vec2.inplace_copy = function (dst, src) { | 82 | */ |
83 | dst[0] = src[0]; | 83 | RDGE.vec2.inplace_copy = function (dst, src) { |
84 | dst[1] = src[1]; | 84 | dst[0] = src[0]; |
85 | }; | 85 | dst[1] = src[1]; |
86 | 86 | }; | |
87 | /** | 87 | |
88 | * RDGE.vec2.zero | 88 | /** |
89 | */ | 89 | * RDGE.vec2.zero |
90 | RDGE.vec2.zero = function () { | 90 | */ |
91 | return [0.0, 0.0]; | 91 | RDGE.vec2.zero = function () { |
92 | }; | 92 | return [0.0, 0.0]; |
93 | 93 | }; | |
94 | /** | 94 | |
95 | * RDGE.vec2.up | 95 | /** |
96 | */ | 96 | * RDGE.vec2.up |
97 | RDGE.vec2.up = function () { | 97 | */ |
98 | return [0.0, 1.0]; | 98 | RDGE.vec2.up = function () { |
99 | }; | 99 | return [0.0, 1.0]; |
100 | 100 | }; | |
101 | /** | 101 | |
102 | * RDGE.vec2.right | 102 | /** |
103 | */ | 103 | * RDGE.vec2.right |
104 | RDGE.vec2.right = function () { | 104 | */ |
105 | return [1.0, 0.0]; | 105 | RDGE.vec2.right = function () { |
106 | }; | 106 | return [1.0, 0.0]; |
107 | 107 | }; | |
108 | /** | 108 | |
109 | * RDGE.vec2.add | 109 | /** |
110 | */ | 110 | * RDGE.vec2.add |
111 | RDGE.vec2.add = function (a, b) { | 111 | */ |
112 | return [a[0] + b[0], a[1] + b[1]]; | 112 | RDGE.vec2.add = function (a, b) { |
113 | }; | 113 | return [a[0] + b[0], a[1] + b[1]]; |
114 | /** | 114 | }; |
115 | * RDGE.vec2.sub | 115 | /** |
116 | */ | 116 | * RDGE.vec2.sub |
117 | RDGE.vec2.sub = function (a, b) { | 117 | */ |
118 | return [a[0] - b[0], a[1] - b[1]]; | 118 | RDGE.vec2.sub = function (a, b) { |
119 | }; | 119 | return [a[0] - b[0], a[1] - b[1]]; |
120 | 120 | }; | |
121 | /** | 121 | |
122 | * RDGE.vec2.mul | 122 | /** |
123 | */ | 123 | * RDGE.vec2.mul |
124 | RDGE.vec2.mul = function (a, b) { | 124 | */ |
125 | return [a[0] * b[0], a[1] * b[1]]; | 125 | RDGE.vec2.mul = function (a, b) { |
126 | }; | 126 | return [a[0] * b[0], a[1] * b[1]]; |
127 | 127 | }; | |
128 | /** | 128 | |
129 | * RDGE.vec2.addMul | 129 | /** |
130 | */ | 130 | * RDGE.vec2.addMul |
131 | RDGE.vec2.addMul = function (a, b, s) { | 131 | */ |
132 | if (s.length != undefined && s.length >= 2) { | 132 | RDGE.vec2.addMul = function (a, b, s) { |
133 | return [a[0] + b[0] * s[0], a[1] + b[1] * s[1]]; | 133 | if (s.length != undefined && s.length >= 2) { |
134 | } else { | 134 | return [a[0] + b[0] * s[0], a[1] + b[1] * s[1]]; |
135 | return [a[0] + b[0] * s, a[1] + b[1] * s]; | 135 |