Class Vector2

Hierarchy

  • Vector2

Constructors

  • Constructor for Vector2 class

    Parameters

    • x: number = 0

      The initial x coordinate of the Vector2

    • y: number = 0

      The initial y coordinate of the Vector2

    Returns Vector2

Properties

x: number
y: number
DOWN: Vector2 = ...
LEFT: Vector2 = ...
ONE: Vector2 = ...
RIGHT: Vector2 = ...
UP: Vector2 = ...
X_AXIS: Vector2 = Vector2.RIGHT
Y_AXIS: Vector2 = Vector2.UP
ZERO: Vector2 = ...

Methods

  • Calculates the angle between this Vector2 and another Vector2

    Returns

    The angle between the two Vector2 objects

    Parameters

    • v: Vector2

      The Vector2 to calculate the angle between

    Returns number

  • Calculates the signed angle between this Vector2 and another Vector2

    Returns

    The signed angle between the two Vector2 objects

    Parameters

    • v: Vector2

      The Vector2 to calculate the angle between

    Returns number

  • Calculates the distance between this Vector2 and another Vector2

    Returns

    The distance between the two Vector2 objects

    Parameters

    • v: Vector2

      The Vector2 to calculate the distance to

    Returns number

  • Divides the components of this Vector2 by a given Vector2

    Parameters

    • v: Vector2

      The Vector2 to divide this Vector2 by

    Returns void

  • Divides the Vector2 by a scalar value

    Parameters

    • n: number

      The scalar value to divide by

    Returns void

  • Calculates the dot product of this Vector2 and another Vector2

    Returns

    The dot product of the two Vector2 objects

    Parameters

    • v: Vector2

      The Vector2 to calculate the dot product with

    Returns number

  • Checks if two Vector2 objects have the same coordinates

    Returns

    true if the coordinates of both Vector2 objects are the same, false otherwise

    Parameters

    • v: Vector2

      The Vector2 object to compare

    Returns boolean

  • Calculates the length of this Vector2

    Returns

    The length of this Vector2

    Returns number

  • Calculates the linear interpolation between two Vector2 objects

    Parameters

    • v1: Vector2

      The first Vector2 object

    • v2: Vector2

      The second Vector2 object

    • alpha: number

      The interpolation value between 0 and 1

    Returns void

  • Multiplies the components of a given Vector2 by this Vector2

    Parameters

    • v: Vector2

      The Vector2 to multiply this Vector2 by

    Returns void

  • Multiplies the Vector2 by a scalar value

    Parameters

    • n: number

      The scalar value to multiply by

    Returns void

  • Rotates this Vector2 by a given angle

    Parameters

    • angle: number

      The angle to rotate by in radians

    Returns void

  • Sets the coordinates of the Vector2

    Parameters

    • x: number

      The new x coordinate of the Vector2

    • y: number

      The new y coordinate of the Vector2

    Returns void

  • Sets the position of this Vector2 from a Matrix3

    Parameters

    • m: Matrix3

      The Matrix3 to get the position from

    Returns void

  • Sets the scale of this Vector2 from a Matrix3

    Parameters

    • m: Matrix3

      The Matrix3 to get the scale from

    Returns void

  • Subtracts the components of a given Vector2 from this Vector2

    Parameters

    • v: Vector2

      The Vector2 to subtract from this Vector2

    Returns void

  • Transforms this Vector2 object with a Matrix3

    Parameters

    • m: Matrix3

      The Matrix3 to transform this Vector2 with

    Returns void

  • Transforms this Vector2 object with a Matrix3, ignoring the translation component

    Parameters

    • m: Matrix3

      The Matrix3 to transform this Vector2 with

    Returns void

  • Computes the angle between two Vector2 objects

    Returns

    The angle between the two input vectors

    Parameters

    • v1: Vector2

      The first Vector2 object

    • v2: Vector2

      The second Vector2 object

    Returns number

  • Computes the angle between two Vector2 objects with sign

    Returns

    The signed angle between the two input vectors

    Parameters

    • v1: Vector2

      The first Vector2 object

    • v2: Vector2

      The second Vector2 object

    Returns number

  • Computes the distance between two Vector2 objects

    Returns

    The distance between the two input vectors

    Parameters

    • v1: Vector2

      The first Vector2 object

    • v2: Vector2

      The second Vector2 object

    Returns number

  • Divides a Vector2 object by a scalar and returns the result in a new Vector2

    Returns

    A new Vector2 object with the result of the division

    Parameters

    • v: Vector2

      The Vector2 object

    • n: number

      The scalar

    Returns Vector2

  • Computes the dot product of two Vector2 objects

    Returns

    The dot product of the two input vectors

    Parameters

    • v1: Vector2

      The first Vector2 object

    • v2: Vector2

      The second Vector2 object

    Returns number

  • Linearly interpolates between two Vector2 objects

    Returns

    The interpolated Vector2

    Parameters

    • v1: Vector2

      The first Vector2 object

    • v2: Vector2

      The second Vector2 object

    • alpha: number

      The interpolation value between 0 and 1

    Returns Vector2

  • Multiplies a Vector2 object by a scalar and returns the result in a new Vector2

    Returns

    A new Vector2 object with the result of the multiplication

    Parameters

    • v: Vector2

      The Vector2 object

    • n: number

      The scalar

    Returns Vector2

  • Rotates an input Vector2 by a given angle

    Returns

    The rotated Vector2

    Parameters

    • v: Vector2

      The Vector2 object to be rotated

    • angle: number

      The angle to rotate the Vector2 by

    Returns Vector2

  • Transforms an input Vector2 as a direction by a given Matrix3, ignoring the translation component

    Returns

    The transformed Vector2

    Parameters

    • v: Vector2

      The Vector2 object to be transformed

    • m: Matrix3

      The Matrix3 to transform the Vector2 by

    Returns Vector2

Generated using TypeDoc