1 /**
  2  * @author mrdoob / http://mrdoob.com/
  3  * @author kile / http://kile.stravaganza.org/
  4  * @author philogb / http://blog.thejit.org/
  5  * @author mikael emtinger / http://gomo.se/
  6  * @author egraether / http://egraether.com/
  7  * @author WestLangley / http://github.com/WestLangley
  8  */
  9 
 10 /**@constructor*/
 11 THREE.Vector3 = function ( x, y, z ) {
 12 
 13 	this.x = x || 0;
 14 	this.y = y || 0;
 15 	this.z = z || 0;
 16 
 17 };
 18 
 19 
 20 THREE.Vector3.prototype = {
 21 
 22 	constructor: THREE.Vector3,
 23 
 24 	set: function ( x, y, z ) {
 25 
 26 		this.x = x;
 27 		this.y = y;
 28 		this.z = z;
 29 
 30 		return this;
 31 
 32 	},
 33 
 34 	setX: function ( x ) {
 35 
 36 		this.x = x;
 37 
 38 		return this;
 39 
 40 	},
 41 
 42 	setY: function ( y ) {
 43 
 44 		this.y = y;
 45 
 46 		return this;
 47 
 48 	},
 49 
 50 	setZ: function ( z ) {
 51 
 52 		this.z = z;
 53 
 54 		return this;
 55 
 56 	},
 57 
 58 	copy: function ( v ) {
 59 
 60 		this.x = v.x;
 61 		this.y = v.y;
 62 		this.z = v.z;
 63 
 64 		return this;
 65 
 66 	},
 67 
 68 	add: function ( a, b ) {
 69 
 70 		this.x = a.x + b.x;
 71 		this.y = a.y + b.y;
 72 		this.z = a.z + b.z;
 73 
 74 		return this;
 75 
 76 	},
 77 
 78 	addSelf: function ( v ) {
 79 
 80 		this.x += v.x;
 81 		this.y += v.y;
 82 		this.z += v.z;
 83 
 84 		return this;
 85 
 86 	},
 87 
 88 	addScalar: function ( s ) {
 89 
 90 		this.x += s;
 91 		this.y += s;
 92 		this.z += s;
 93 
 94 		return this;
 95 
 96 	},
 97 
 98 	sub: function ( a, b ) {
 99 
100 		this.x = a.x - b.x;
101 		this.y = a.y - b.y;
102 		this.z = a.z - b.z;
103 
104 		return this;
105 
106 	},
107 
108 	subSelf: function ( v ) {
109 
110 		this.x -= v.x;
111 		this.y -= v.y;
112 		this.z -= v.z;
113 
114 		return this;
115 
116 	},
117 
118 	multiply: function ( a, b ) {
119 
120 		this.x = a.x * b.x;
121 		this.y = a.y * b.y;
122 		this.z = a.z * b.z;
123 
124 		return this;
125 
126 	},
127 
128 	multiplySelf: function ( v ) {
129 
130 		this.x *= v.x;
131 		this.y *= v.y;
132 		this.z *= v.z;
133 
134 		return this;
135 
136 	},
137 
138 	multiplyScalar: function ( s ) {
139 
140 		this.x *= s;
141 		this.y *= s;
142 		this.z *= s;
143 
144 		return this;
145 
146 	},
147 
148 	divideSelf: function ( v ) {
149 
150 		this.x /= v.x;
151 		this.y /= v.y;
152 		this.z /= v.z;
153 
154 		return this;
155 
156 	},
157 
158 	divideScalar: function ( s ) {
159 
160 		if ( s ) {
161 
162 			this.x /= s;
163 			this.y /= s;
164 			this.z /= s;
165 
166 		} else {
167 
168 			this.x = 0;
169 			this.y = 0;
170 			this.z = 0;
171 
172 		}
173 
174 		return this;
175 
176 	},
177 
178 
179 	negate: function() {
180 
181 		return this.multiplyScalar( - 1 );
182 
183 	},
184 
185 	dot: function ( v ) {
186 
187 		return this.x * v.x + this.y * v.y + this.z * v.z;
188 
189 	},
190 
191 	lengthSq: function () {
192 
193 		return this.x * this.x + this.y * this.y + this.z * this.z;
194 
195 	},
196 
197 	length: function () {
198 
199 		return Math.sqrt( this.lengthSq() );
200 
201 	},
202 
203 	lengthManhattan: function () {
204 
205 		return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
206 
207 	},
208 
209 	normalize: function () {
210 
211 		return this.divideScalar( this.length() );
212 
213 	},
214 
215 	setLength: function ( l ) {
216 
217 		return this.normalize().multiplyScalar( l );
218 
219 	},
220 
221 	lerpSelf: function ( v, alpha ) {
222 
223 		this.x += ( v.x - this.x ) * alpha;
224 		this.y += ( v.y - this.y ) * alpha;
225 		this.z += ( v.z - this.z ) * alpha;
226 
227 		return this;
228 
229 	},
230 
231 	cross: function ( a, b ) {
232 
233 		this.x = a.y * b.z - a.z * b.y;
234 		this.y = a.z * b.x - a.x * b.z;
235 		this.z = a.x * b.y - a.y * b.x;
236 
237 		return this;
238 
239 	},
240 
241 	crossSelf: function ( v ) {
242 
243 		var x = this.x, y = this.y, z = this.z;
244 
245 		this.x = y * v.z - z * v.y;
246 		this.y = z * v.x - x * v.z;
247 		this.z = x * v.y - y * v.x;
248 
249 		return this;
250 
251 	},
252 
253 	angleTo: function ( v ) {
254 
255 		return Math.acos( this.dot( v ) / this.length() / v.length() );
256 
257 	},
258 
259 	distanceTo: function ( v ) {
260 
261 		return Math.sqrt( this.distanceToSquared( v ) );
262 
263 	},
264 
265 	distanceToSquared: function ( v ) {
266 
267 		return new THREE.Vector3().sub( this, v ).lengthSq();
268 
269 	},
270 
271 	getPositionFromMatrix: function ( m ) {
272 
273 		this.x = m.elements[12];
274 		this.y = m.elements[13];
275 		this.z = m.elements[14];
276 
277 		return this;
278 
279 	},
280 
281 	setEulerFromRotationMatrix: function ( m, order ) {
282 
283 		// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
284 
285 		// clamp, to handle numerical problems
286 
287 		function clamp( x ) {
288 
289 			return Math.min( Math.max( x, -1 ), 1 );
290 
291 		}
292 
293 		var te = m.elements;
294 		var m11 = te[0], m12 = te[4], m13 = te[8];
295 		var m21 = te[1], m22 = te[5], m23 = te[9];
296 		var m31 = te[2], m32 = te[6], m33 = te[10];
297 
298 		if ( order === undefined || order === 'XYZ' ) {
299 
300 			this.y = Math.asin( clamp( m13 ) );
301 
302 			if ( Math.abs( m13 ) < 0.99999 ) {
303 
304 				this.x = Math.atan2( - m23, m33 );
305 				this.z = Math.atan2( - m12, m11 );
306 
307 			} else {
308 
309 				this.x = Math.atan2( m32, m22 );
310 				this.z = 0;
311 
312 			}
313 
314 		} else if ( order === 'YXZ' ) {
315 
316 			this.x = Math.asin( - clamp( m23 ) );
317 
318 			if ( Math.abs( m23 ) < 0.99999 ) {
319 
320 				this.y = Math.atan2( m13, m33 );
321 				this.z = Math.atan2( m21, m22 );
322 
323 			} else {
324 
325 				this.y = Math.atan2( - m31, m11 );
326 				this.z = 0;
327 
328 			}
329 
330 		} else if ( order === 'ZXY' ) {
331 
332 			this.x = Math.asin( clamp( m32 ) );
333 
334 			if ( Math.abs( m32 ) < 0.99999 ) {
335 
336 				this.y = Math.atan2( - m31, m33 );
337 				this.z = Math.atan2( - m12, m22 );
338 
339 			} else {
340 
341 				this.y = 0;
342 				this.z = Math.atan2( m21, m11 );
343 
344 			}
345 
346 		} else if ( order === 'ZYX' ) {
347 
348 			this.y = Math.asin( - clamp( m31 ) );
349 
350 			if ( Math.abs( m31 ) < 0.99999 ) {
351 
352 				this.x = Math.atan2( m32, m33 );
353 				this.z = Math.atan2( m21, m11 );
354 
355 			} else {
356 
357 				this.x = 0;
358 				this.z = Math.atan2( - m12, m22 );
359 
360 			}
361 
362 		} else if ( order === 'YZX' ) {
363 
364 			this.z = Math.asin( clamp( m21 ) );
365 
366 			if ( Math.abs( m21 ) < 0.99999 ) {
367 
368 				this.x = Math.atan2( - m23, m22 );
369 				this.y = Math.atan2( - m31, m11 );
370 
371 			} else {
372 
373 				this.x = 0;
374 				this.y = Math.atan2( m13, m33 );
375 
376 			}
377 
378 		} else if ( order === 'XZY' ) {
379 
380 			this.z = Math.asin( - clamp( m12 ) );
381 
382 			if ( Math.abs( m12 ) < 0.99999 ) {
383 
384 				this.x = Math.atan2( m32, m22 );
385 				this.y = Math.atan2( m13, m11 );
386 
387 			} else {
388 
389 				this.x = Math.atan2( - m23, m33 );
390 				this.y = 0;
391 
392 			}
393 
394 		}
395 
396 		return this;
397 
398 	},
399 
400 	setEulerFromQuaternion: function ( q, order ) {
401 
402 		// q is assumed to be normalized
403 
404 		// clamp, to handle numerical problems
405 
406 		function clamp( x ) {
407 
408 			return Math.min( Math.max( x, -1 ), 1 );
409 
410 		}
411 
412 		// http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
413 
414 		var sqx = q.x * q.x;
415 		var sqy = q.y * q.y;
416 		var sqz = q.z * q.z;
417 		var sqw = q.w * q.w;
418 
419 		if ( order === undefined || order === 'XYZ' ) {
420 
421 			this.x = Math.atan2( 2 * ( q.x * q.w - q.y * q.z ), ( sqw - sqx - sqy + sqz ) );
422 			this.y = Math.asin(  clamp( 2 * ( q.x * q.z + q.y * q.w ) ) );
423 			this.z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw + sqx - sqy - sqz ) );
424 
425 		} else if ( order ===  'YXZ' ) {
426 
427 			this.x = Math.asin(  clamp( 2 * ( q.x * q.w - q.y * q.z ) ) );
428 			this.y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw - sqx - sqy + sqz ) );
429 			this.z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw - sqx + sqy - sqz ) );
430 
431 		} else if ( order === 'ZXY' ) {
432 
433 			this.x = Math.asin(  clamp( 2 * ( q.x * q.w + q.y * q.z ) ) );
434 			this.y = Math.atan2( 2 * ( q.y * q.w - q.z * q.x ), ( sqw - sqx - sqy + sqz ) );
435 			this.z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw - sqx + sqy - sqz ) );
436 
437 		} else if ( order === 'ZYX' ) {
438 
439 			this.x = Math.atan2( 2 * ( q.x * q.w + q.z * q.y ), ( sqw - sqx - sqy + sqz ) );
440 			this.y = Math.asin(  clamp( 2 * ( q.y * q.w - q.x * q.z ) ) );
441 			this.z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw + sqx - sqy - sqz ) );
442 
443 		} else if ( order === 'YZX' ) {
444 
445 			this.x = Math.atan2( 2 * ( q.x * q.w - q.z * q.y ), ( sqw - sqx + sqy - sqz ) );
446 			this.y = Math.atan2( 2 * ( q.y * q.w - q.x * q.z ), ( sqw + sqx - sqy - sqz ) );
447 			this.z = Math.asin(  clamp( 2 * ( q.x * q.y + q.z * q.w ) ) );
448 
449 		} else if ( order === 'XZY' ) {
450 
451 			this.x = Math.atan2( 2 * ( q.x * q.w + q.y * q.z ), ( sqw - sqx + sqy - sqz ) );
452 			this.y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw + sqx - sqy - sqz ) );
453 			this.z = Math.asin(  clamp( 2 * ( q.z * q.w - q.x * q.y ) ) );
454 
455 		}
456 
457 		return this;
458 
459 	},
460 
461 	getScaleFromMatrix: function ( m ) {
462 
463 		var sx = this.set( m.elements[0], m.elements[1], m.elements[2] ).length();
464 		var sy = this.set( m.elements[4], m.elements[5], m.elements[6] ).length();
465 		var sz = this.set( m.elements[8], m.elements[9], m.elements[10] ).length();
466 
467 		this.x = sx;
468 		this.y = sy;
469 		this.z = sz;
470 
471 		return this;
472 	},
473 
474 	equals: function ( v ) {
475 
476 		return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
477 
478 	},
479 
480 	clone: function () {
481 
482 		return new THREE.Vector3( this.x, this.y, this.z );
483 
484 	}
485 
486 };
487 

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

mbt skor nike sverige louboutin skor hollister sverige polo ralph lauren skjorta woolrich jacka dam canada goose jacka woolrich jacka ray ban rea canada goose rea michael kors rea new balance skor ralph lauren skjorta new balance rea uggs sverige lacoste rea christian louboutin skor moncler jacka nike shox barbour jacka uggs rea