Class Vector2

A point in 2D space using a cartesian coordinate system. Includes extra methods for math and utility.

-X is left. +X is right. -Y is up. +Y is down.

Hierarchy

  • Vector2

Implements

Constructors

Properties

x: number

The x coordinate of a 2D point.

y: number

The y coordinate of a 2D point.

Accessors

  • get abs(): Vector2
  • Takes the absolute value of the x and y of the Vector2. Creates a new Vector2 and does not modify the original Vector2.

    Returns Vector2

  • get deg(): number
  • Returns the clockwise angle in degrees from the x-axis to the Vector2.

    Returns number

  • get dist(): number
  • Returns the distance from the origin to the Vector2.

    Returns number

  • get distSquared(): number
  • Returns the square of the distance from the origin to the Vector2. Faster than dist().

    Returns number

  • get normalizationFactor(): number
  • The scale factor required to normalize the Vector2. Returns 1 if the distance from the origin is 0.

    Returns number

  • get rad(): number
  • Returns the clockwise angle in radians from the x-axis to the Vector2.

    Returns number

  • get string(): string
  • Returns the string form of a Vector2 in the form (x, y). Same as toString().

    Returns string

Methods

  • Returns the square of the distance from the Vector2 to a point. Faster than distTo().

    Parameters

    Returns number

  • Rotates the Vector2 around the origin by a clockwise angle in radians. Creates a new Vector2 and does not modify the original Vector2.

    Parameters

    • rad: number

    Returns Vector2

  • Rotates the Vector2 around another point by a clockwise angle in radians. Creates a new Vector2 and does not modify the original Vector2.

    Parameters

    Returns Vector2

  • Rotates the Vector2 around another point by a clockwise angle in radians. Modifies the original Vector2.

    Parameters

    Returns Vector2

  • Rotates the Vector2 around another point by a clockwise angle in degrees. Creates a new Vector2 and does not modify the original Vector2.

    Parameters

    Returns Vector2

  • Rotates the Vector2 around another point by a clockwise angle in degrees. Modifies the original Vector2.

    Parameters

    Returns Vector2

  • Rotates the Vector2 around the origin by a clockwise angle in radians. Modifies the original Vector2.

    Parameters

    • rad: number

    Returns Vector2

  • Rotates the Vector2 around the origin by a clockwise angle in degrees. Creates a new Vector2 and does not modify the original Vector2.

    Parameters

    • deg: number

    Returns Vector2

  • Rotates the Vector2 around the origin by a clockwise angle in degrees. Modifies the original Vector2.

    Parameters

    • deg: number

    Returns Vector2

  • Scales the Vector2 by a scale factor. Creates a new Vector2 and does not modify the original Vector2.

    Parameters

    • f: number

    Returns Vector2

  • Returns the string form of a Vector2 in the form (x, y). Same as the string property.

    Returns string

  • Moves the Vector2 towards another point by a specified distance. Creates a new Vector2 and does not modify the original Vector2.

    Parameters

    Returns Vector2

Generated using TypeDoc