Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Vector2

Index

Constructors

constructor

  • new Vector2(values?: number[]): Vector2

Properties

Private _values

_values: Float32Array = new Float32Array(2)

Accessors

x

x:

xy

xy:

y

y:

Static zero

zero:

Retrieves a new instance of the vector (0, 0)

Methods

add

  • Adds two vectors together. If no dest vector is specified, the operation is performed in-place.

    Parameters

    Returns Vector2

at

  • at(index: number): number
  • Retrieves the x-component or y-component of the vector.

    Parameters

    • index: number

    Returns number

copy

  • Copies the x- and y-components from one vector to another. If no dest vector is specified, a new vector is instantiated.

    Parameters

    Returns Vector2

divide

equals

  • equals(other: Vector2, threshold?: number): boolean
  • Checks if two vectors are equal, using a threshold to avoid floating-point precision errors.

    Parameters

    • other: Vector2
    • Default value threshold: number = EPSILON

    Returns boolean

length

  • length(): number
  • Returns the distance from the vector to the origin.

    Returns number

multiply

  • Multiplies two vectors together piecewise. If no dest vector is specified, the operation is performed in-place.

    Parameters

    Returns Vector2

negate

  • Multiplies both the x- and y-components of a vector by -1. If no dest vector is specified, the operation is performed in-place.

    Parameters

    Returns Vector2

normalize

  • Normalizes a vector. If no dest vector is specified, the operation is performed in-place.

    Parameters

    Returns Vector2

reset

  • reset(): void
  • Sets both the x- and y-components of the vector to 0.

    Returns void

scale

  • Scales a vector by a scalar parameter. If no dest vector is specified, the operation is performed in-place.

    Parameters

    • value: number
    • Optional dest: Vector2

    Returns Vector2

squaredLength

  • squaredLength(): number
  • Returns the distance from the vector to the origin, squared.

    Returns number

subtract

  • Subtracts one vector from another. If no dest vector is specified, the operation is performed in-place.

    Parameters

    Returns Vector2

toString

  • toString(): string

Static cross

Static difference

Static direction

  • Calculates a normalized vector representing the direction from one vector to another. If no dest vector is specified, a new vector is instantiated.

    Parameters

    Returns Vector2

Static distance

  • Calculates the distance between two vectors

    Parameters

    Returns number

    The distance between the two vectors

Static dot

  • Calculates the dot product of two vectors

    Parameters

    Returns number

    The dot product of the two vectors

Static lerp

  • Performs a linear interpolation over two vectors. If no dest vector is specified, a new vector is instantiated.

    Parameters

    Returns Vector2

Static product

  • Multiplies two vectors piecewise. If no dest vector is specified, a new vector is instantiated.

    Parameters

    Returns Vector2

Static quotient

  • Divides two vectors piecewise. If no dest vector is specified, a new vector is instantiated.

    Parameters

    Returns Vector2

Static squaredDistance

  • Calculates the distance between two vectors squared

    Parameters

    Returns number

    The distance between the two vectors

Static sum

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc