Vector2
2D vector.
Example
var a = new THREE.Vector2( 0, 1 ); var b = new THREE.Vector2( 1, 0 ); var d = a.distanceTo( b );
Constructor
Vector2( x, y )
x --
Float representing the x value of the vector
y --
Float representing the y value of the vector
A vector in 2 dimensional space
Properties
Methods
Sets value of this vector.
replace this vector's x value with x.
replace this vector's y value with y.
Copies value of v to this vector.
array -- The source array of length 2
offset -- An optional offset into the array.
Sets this vector's x value to be array[0] and y value to be array[1].
Adds v to this vector.
Sets this vector to a + b.
Adds the multiple of v and s to this vector.
Subtracts v from this vector.
Sets this vector to a - b.
Multiplies this vector by scalar s.
Divides this vector by scalar s.
Set vector to ( 0, 0 ) if s == 0.
Inverts this vector.
Computes dot product of this vector and v.
Computes the squared length of this vector.
Computes the length of this vector.
Normalizes this vector.
Computes the angle in radians of this vector with respect to the positive x-axis.
Computes the distance from this vector to v.
Computes the squared distance from this vector to v.
Computes the Manhattan distance from this vector to v.
Normalizes this vector and multiplies it by l.
min --
Vector2 containing the min x and y values in the desired range
max --
Vector2 containing the max x and y values in the desired range
If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value.
If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
min --
Float the minimum value the components will be clamped to
max --
Float the maximum value the components will be clamped to
If this vector's x or y values are greater than the max value, they are replaced by the max value.
If this vector's x or y values are less than the min value, they are replaced by the min value.
min --
Float the minimum value the length will be clamped to
max --
Float the maximum value the length will be clamped to
If this vector's length is greater than the max value, it is replaced by the max value.
If this vector's length is less than the min value, it is replaced by the min value.
The components of the vector are rounded downwards (towards negative infinity) to an integer value.
The components of the vector are rounded upwards (towards positive infinity) to an integer value.
The components of the vector are rounded towards the nearest integer value.
The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
Linear interpolation between this vector and v, where alpha is the percent along the line.
Sets this vector to be the vector linearly interpolated between v1 and v2 with alpha factor.
index -- 0 or 1
value --
Float
if index equals 0 method replaces this.x with value.
if index equals 1 method replaces this.y with value.
Add the scalar value s to this vector's x and y values.
index -- 0 or 1
if index equals 0 returns the x value.
if index equals 1 returns the y value.
If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value.
If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value.
Checks for strict equality of this vector and v.
Clones this vector.
array -- An optional array to store the vector to.
offset -- An optional offset into the array.
Returns an array [x, y].
Source
src/math/Vector2.js
Edit