2D vector.
Methods
Adds v to this vector.
Parameters
Returns
Vector2
public addScalar(s: number): Vector2
Parameters
Returns
Vector2
Sets this vector to a + b.
Parameters
Returns
Vector2
Parameters
Returns
Vector2
public clampScalar(min: number, max: number): Vector2
Parameters
Returns
Vector2
public clone(): Vector2
Clones this vector.
Returns
Vector2
Copies value of v to this vector.
Parameters
Returns
Vector2
public distanceTo(v: Vector2): number
Computes distance of this vector to v.
Parameters
Returns
number
public distanceToSquared(v: Vector2): number
Computes squared distance of this vector to v.
Parameters
Returns
number
public divideScalar(s: number): Vector2
Divides this vector by scalar s.
Set vector to ( 0, 0 ) if s == 0.
Parameters
Returns
Vector2
public dot(v: Vector2): number
Computes dot product of this vector and v.
Parameters
Returns
number
public equals(v: Vector2): boolean
Checks for strict equality of this vector and v.
Parameters
Returns
boolean
public fromArray(xy: Array<number>): Vector2
Parameters
Returns
Vector2
public getComponent(index: number): number
Gets a component of this vector.
Parameters
Returns
number
public length(): number
Computes length of this vector.
Returns
number
public lengthSq(): number
Computes squared length of this vector.
Returns
number
Parameters
Returns
Vector2
Parameters
Returns
Vector2
public multiplyScalar(s: number): Vector2
Multiplies this vector by scalar s.
Parameters
Returns
Vector2
public negate(): Vector2
Inverts this vector.
Returns
Vector2
public normalize(): Vector2
Normalizes this vector.
Returns
Vector2
public roundToZero(): Vector2
Returns
Vector2
public set(x: number, y: number): Vector2
Sets value of this vector.
Parameters
Returns
Vector2
public setComponent(index: number, value: number)
Sets a component of this vector.
Parameters
-
index: number
-
value: number
public setLength(l: number): Vector2
Normalizes this vector and multiplies it by l.
Parameters
Returns
Vector2
public setX(x: number): Vector2
Sets X component of this vector.
Parameters
Returns
Vector2
public setY(y: number): Vector2
Sets Y component of this vector.
Parameters
Returns
Vector2
Subtracts v from this vector.
Parameters
Returns
Vector2
Sets this vector to a - b.
Parameters
Returns
Vector2
public toArray(): Array<number>
Returns
Array<number>