Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vector2

Hierarchy

  • Vector2

Index

Constructors

constructor

  • Parameters

    • x: number
    • y: number

    Returns Vector2

  • Parameters

    • arr: [number, number]

    Returns Vector2

  • Parameters

    Returns Vector2

  • Parameters

    • value: number

    Returns Vector2

Properties

Readonly x

x: number

Readonly y

y: number

Static Readonly down

down: Vector2

(0, -1) vector

Static Readonly left

left: Vector2

(-1, 0) vector

Static Readonly negativeInfinity

negativeInfinity: Vector2

(-Infinity, -Infinity) vector

Static Readonly one

one: Vector2

(1, 1) vector

Static Readonly positiveInfinity

positiveInfinity: Vector2

(Infinity, Infinity) vector

Static Readonly right

right: Vector2

(1, 0) vector

Static Readonly up

(0, 1) vector

Static Readonly zero

zero: Vector2

(0, 0) vector

Accessors

length

  • get length(): number
  • Returns number

Methods

add

  • Adds two vectors.

    Parameters

    • x: number
    • y: number

    Returns Vector2

  • Adds a number to all vector axis.

    Parameters

    • value: number

    Returns Vector2

  • Adds two vectors.

    Parameters

    • array: [number, number]

    Returns Vector2

  • Adds two vectors.

    Parameters

    Returns Vector2

angleTo

  • Calculates angle between to vectors (in radians).

    Parameters

    Returns Vector2

angleToDegrees

  • Calculates angle between to vectors (in degrees).

    Parameters

    Returns Vector2

distanceTo

  • Calculates distance between vectors.

    Parameters

    Returns number

distanceToSquared

  • distanceToSquared(vector: IVector2): number
  • Calculates squared distance between vectors.

    Parameters

    Returns number

div

  • Divides two vectors.

    Parameters

    • x: number
    • y: number

    Returns Vector2

  • Divides two vectors.

    Parameters

    • value: number

    Returns Vector2

  • Divides two vectors.

    Parameters

    • array: [number, number]

    Returns Vector2

  • Divides two vectors.

    Parameters

    Returns Vector2

dot

  • Calculates dot product between two vectors.

    Parameters

    • x: number
    • y: number

    Returns Vector2

  • Calculates dot product between vector and a number.

    Parameters

    • value: number

    Returns Vector2

  • Calculates dot product between two vectors.

    Parameters

    • array: [number, number]

    Returns Vector2

  • Calculates dot product between two vectors.

    Parameters

    Returns Vector2

inverse

  • Returns Vector2

isInRange

  • isInRange(vector: IVector2, range: number): boolean
  • Checks if distance between vectors is smaller or equal to range.

    Parameters

    Returns boolean

lerp

  • Interpolates vectors linearly.

    Parameters

    Returns Vector2

mul

  • Multiplies two vectors.

    Parameters

    • x: number
    • y: number

    Returns Vector2

  • Multiplies all vector axis by a number.

    Parameters

    • value: number

    Returns Vector2

  • Multiplies two vectors.

    Parameters

    • array: [number, number]

    Returns Vector2

  • Multiplies two vectors.

    Parameters

    Returns Vector2

negative

  • Negates vector.

    Returns Vector2

normalize

  • Normalizes vector.

    Returns Vector2

sub

  • Subtracts two vectors.

    Parameters

    • x: number
    • y: number

    Returns Vector2

  • Subtracts a number from all vector axis.

    Parameters

    • value: number

    Returns Vector2

  • Subtracts two vectors.

    Parameters

    • array: [number, number]

    Returns Vector2

  • Subtracts two vectors.

    Parameters

    Returns Vector2

toArray

  • toArray(): [number, number]
  • Returns [x, y] array.

    Returns [number, number]

toDegrees

  • Converts radians to degrees.

    Returns Vector2

toFixed

  • toFixed(precision: number): Vector2
  • Parameters

    • precision: number

    Returns Vector2

toRadians

  • Converts degrees to radians.

    Returns Vector2

toString

  • toString(): string
  • Returns string