A 2-dimensional vector.

Methods that manipulate values are generally destructive. To preserve the original values, explicitly call clone() to create a duplicate instance.

Hierarchy

  • Vector2

Constructors

Properties

x: number
y: number

Methods

  • Adds the scalar value s to the vector's x and y components.

    Parameters

    • s: number

    Returns Vector2

  • Returns the size of the 2-dimensional cross product of the vector and v.

    Parameters

    Returns number

  • Divides the vector by the scalar value s.

    Parameters

    • s: number

    Returns Vector2

  • Returns the dot product of the vector and v.

    Parameters

    Returns number

  • Compares the vector to v, and returns true if they are approximately equal.

    Parameters

    Returns boolean

  • Returns the vector's length.

    Returns number

  • Returns the vector's squared length.

    Returns number

  • Calculates the linear interpolation (lerp) between the current value and v, using a as the interpolation factor, then updates the vector's value to the result.

    Parameters

    • v: Vector2
    • a: number

      The interpolation factor, specified as a number between [0, 1].

    Returns Vector2

  • Multiplies the vector by the scalar value s.

    Parameters

    • s: number

    Returns Vector2

  • Sets the vector's component values to those specified in x and y.

    Parameters

    • x: number
    • y: number

    Returns Vector2

  • Subtracts the scalar value s from the vector's x and y components.

    Parameters

    • s: number

    Returns Vector2

Generated using TypeDoc