1 /**
2 * @author mrdoob / http://mrdoob.com/
3 * @author philogb / http://blog.thejit.org/
4 * @author egraether / http://egraether.com/
5 * @author zz85 / http://www.lab4games.net/zz85/blog
6 */
7
8 /**@constructor*/
9 THREE.Vector2 = function ( x, y ) {
10
11 this.x = x || 0;
12 this.y = y || 0;
13
14 };
15
16 THREE.Vector2.prototype = {
17
18 constructor: THREE.Vector2,
19
20 set: function ( x, y ) {
21
22 this.x = x;
23 this.y = y;
24
25 return this;
26
27 },
28
29 copy: function ( v ) {
30
31 this.x = v.x;
32 this.y = v.y;
33
34 return this;
35
36 },
37
38 add: function ( a, b ) {
39
40 this.x = a.x + b.x;
41 this.y = a.y + b.y;
42
43 return this;
44
45 },
46
47 addSelf: function ( v ) {
48
49 this.x += v.x;
50 this.y += v.y;
51
52 return this;
53
54 },
55
56 sub: function ( a, b ) {
57
58 this.x = a.x - b.x;
59 this.y = a.y - b.y;
60
61 return this;
62
63 },
64
65 subSelf: function ( v ) {
66
67 this.x -= v.x;
68 this.y -= v.y;
69
70 return this;
71
72 },
73
74 multiplyScalar: function ( s ) {
75
76 this.x *= s;
77 this.y *= s;
78
79 return this;
80
81 },
82
83 divideScalar: function ( s ) {
84
85 if ( s ) {
86
87 this.x /= s;
88 this.y /= s;
89
90 } else {
91
92 this.set( 0, 0 );
93
94 }
95
96 return this;
97
98 },
99
100 negate: function() {
101
102 return this.multiplyScalar( - 1 );
103
104 },
105
106 dot: function ( v ) {
107
108 return this.x * v.x + this.y * v.y;
109
110 },
111
112 lengthSq: function () {
113
114 return this.x * this.x + this.y * this.y;
115
116 },
117
118 length: function () {
119
120 return Math.sqrt( this.lengthSq() );
121
122 },
123
124 normalize: function () {
125
126 return this.divideScalar( this.length() );
127
128 },
129
130 distanceTo: function ( v ) {
131
132 return Math.sqrt( this.distanceToSquared( v ) );
133
134 },
135
136 distanceToSquared: function ( v ) {
137
138 var dx = this.x - v.x, dy = this.y - v.y;
139 return dx * dx + dy * dy;
140
141 },
142
143 setLength: function ( l ) {
144
145 return this.normalize().multiplyScalar( l );
146
147 },
148
149 lerpSelf: function ( v, alpha ) {
150
151 this.x += ( v.x - this.x ) * alpha;
152 this.y += ( v.y - this.y ) * alpha;
153
154 return this;
155
156 },
157
158 equals: function( v ) {
159
160 return ( ( v.x === this.x ) && ( v.y === this.y ) );
161
162 },
163
164 clone: function () {
165
166 return new THREE.Vector2( this.x, this.y );
167
168 }
169
170 };
171
nike free rn
new balance hombre baratas
cinturones gucci
ugg rebajas
cinturon gucci
ray ban baratas
nike cortez
peuterey mujer
christian louboutin madrid
mbt zapatos
gafas ray ban baratas
mbt ofertas
air max blancas
mbt barcelona
nike air max 90
woolrich barcelona
nike mujer
botas ugg
gafas de sol carrera aratas
air max 2016 baratas
oakley baratas
nike air max 2016