[name]

2D Vector.

Example

var a = new THREE.Vector2( 0, 1 ); var b = new THREE.Vector2( 1, 0 ); var d = a.distanceTo( b );

Constructor

[name]( [page:Float x], [page:Float y] )

Properties

.[page:Float x]

.[page:Float y]

Methods

.set( [page:Float x], [page:Float y] ) [page:Vector2]

Sets value of this vector.

.copy( [page:Vector2 v] ) [page:Vector2]

Copies value of *v* to this vector.

.add( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2]

Sets this vector to *a + b*.

.addSelf( [page:Vector2 v] ) [page:Vector2]

Adds *v* to this vector.

.sub( [page:Vector2 a], [page:Vector2 b] ) [page:Vector2]

Sets this vector to *a - b*.

.subSelf( [page:Vector2 v] ) [page:Vector2]

Subtracts *v* from this vector.

.multiplyScalar( [page:Float s] ) [page:Vector2]

Multiplies this vector by scalar *s*.

.divideScalar( [page:Float s] ) [page:Vector2]

Divides this vector by scalar *s*.
Set vector to *( 0, 0 )* if *s == 0*.

.negate() [page:Vector2]

Inverts this vector.

.dot( [page:Vector2 v] ) [page:Float]

Computes dot product of this vector and *v*.

.lengthSq() [page:Float]

Computes squared length of this vector.

.length() [page:Float]

Computes length of this vector.

.normalize() [page:Vector2]

Normalizes this vector.

.distanceTo( [page:Vector2 v] ) [page:Float]

Computes distance of this vector to *v*.

.distanceToSquared( [page:Vector2 v] ) [page:Float]

Computes squared distance of this vector to *v*.

.setLength( [page:Float l] ) [page:Vector2]

Normalizes this vector and multiplies it by *l*.

.equals( [page:Vector2 v] ) [page:Vector2]

Checks for strict equality of this vector and *v*.

.isZero() [page:Boolean]

Checks if length of this vector is within small epsilon (*0.0001*).

.clone() [page:Vector2]

Clones this vector.

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]