aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/math/vec2.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 12:34:53 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit3644cb6def4f681c99959e5729e78ea353441fad (patch)
treef8a886f4829e507cc4956db37cff2580cae6003d /js/helper-classes/RDGE/src/core/script/math/vec2.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/math/vec2.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/vec2.js432
1 files changed, 216 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 e5c7df06..c62e57ab 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,216 @@
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/** 32/**
33* RDGE.vec2 = {} 33* RDGE.vec2 = {}
34* This library contains functions for operating on 2D vectors. 34* This library contains functions for operating on 2D vectors.
35* A 2D vector can be any array containing at least 2 numeric components. 35* A 2D vector can be any array containing at least 2 numeric components.
36* All of the following are valid methods for declaring a RDGE.vec2: 36* All of the following are valid methods for declaring a RDGE.vec2:
37* var a = [0, 1]; 37* var a = [0, 1];
38* var b = RDGE.vec2.zero(); 38* var b = RDGE.vec2.zero();
39* var c = RDGE.vec2.up(); 39* var c = RDGE.vec2.up();
40*/ 40*/
41var RDGE = RDGE || {}; 41var RDGE = RDGE || {};
42RDGE.vec2 = {}; 42RDGE.vec2 = {};
43 43
44/** 44/**
45* RDGE.vec2.string 45* RDGE.vec2.string
46*/ 46*/
47RDGE.vec2.string = function (v) { 47RDGE.vec2.string = function (v) {
48 return "{ " + v[0] + ", " + v[1] + " }"; 48 return "{ " + v[0] + ", " + v[1] + " }";
49}; 49};
50 50
51/** 51/**
52* RDGE.vec2.verify 52* RDGE.vec2.verify
53* This function is provided for debugging purposes only. It is not recommended 53* This function is provided for debugging purposes only. It is not recommended
54* to be used in performance critical areas of the code. 54* to be used in performance critical areas of the code.
55*/ 55*/
56RDGE.vec2.verify = function (v) { 56RDGE.vec2.verify = function (v) {
57 if (v == undefined || v.length == undefined || v.length < 2) { 57 if (v == undefined || v.length == undefined || v.length < 2) {
58 return false; 58 return false;
59 } 59 }
60 60
61 if (typeof (v[0]) != "number" || typeof (v[1]) != "number") { 61 if (typeof (v[0]) != "number" || typeof (v[1]) != "number") {
62 return false; 62 return false;
63 } 63 }
64 64
65 return true; 65 return true;
66}; 66};
67 67
68/** 68/**
69* RDGE.vec2.copy 69* RDGE.vec2.copy
70*/ 70*/
71RDGE.vec2.copy = function (v) { 71RDGE.vec2.copy = function (v) {
72 if (v.length == undefined) { 72 if (v.length == undefined) {
73 return [v, v]; 73 return [v, v];
74 } 74 }
75 75
76 return [v[0], v[1]]; 76 return [v[0], v[1]];
77}; 77};
78 78
79/** 79/**
80* RDGE.vec2.inplace_copy 80* RDGE.vec2.inplace_copy
81*/ 81*/
82RDGE.vec2.inplace_copy = function (dst, src) { 82RDGE.vec2.inplace_copy = function (dst, src) {
83 dst[0] = src[0]; 83 dst[0] = src[0];
84 dst[1] = src[1]; 84 dst[1] = src[1];
85}; 85};
86 86
87/** 87/**
88* RDGE.vec2.zero 88* RDGE.vec2.zero
89*/ 89*/
90RDGE.vec2.zero = function () { 90RDGE.vec2.zero = function () {
91 return [0.0, 0.0]; 91 return [0.0, 0.0];
92}; 92};
93 93
94/** 94/**
95* RDGE.vec2.up 95* RDGE.vec2.up
96*/ 96*/
97RDGE.vec2.up = function () { 97RDGE.vec2.up = function () {
98 return [0.0, 1.0]; 98 return [0.0, 1.0];
99}; 99};
100 100
101/** 101/**
102* RDGE.vec2.right 102* RDGE.vec2.right
103*/ 103*/
104RDGE.vec2.right = function () { 104RDGE.vec2.right = function () {
105 return [1.0, 0.0]; 105 return [1.0, 0.0];
106}; 106};
107 107
108/** 108/**
109* RDGE.vec2.add 109* RDGE.vec2.add
110*/ 110*/
111RDGE.vec2.add = function (a, b) { 111RDGE.vec2.add = function (a, b) {
112 return [a[0] + b[0], a[1] + b[1]]; 112 return [a[0] + b[0], a[1] + b[1]];
113}; 113};
114/** 114/**
115* RDGE.vec2.sub 115* RDGE.vec2.sub
116*/ 116*/
117RDGE.vec2.sub = function (a, b) { 117RDGE.vec2.sub = function (a, b) {
118 return [a[0] - b[0], a[1] - b[1]]; 118 return [a[0] - b[0], a[1] - b[1]];
119}; 119};
120 120
121/** 121/**
122* RDGE.vec2.mul 122* RDGE.vec2.mul
123*/ 123*/
124RDGE.vec2.mul = function (a, b) { 124RDGE.vec2.mul = function (a, b) {
125 return [a[0] * b[0], a[1] * b[1]]; 125 return [a[0] * b[0], a[1] * b[1]];
126}; 126};
127 127
128/** 128/**
129* RDGE.vec2.addMul 129* RDGE.vec2.addMul
130*/ 130*/
131</