A 2D column vector.

Constructors

  • Creates a new vector 2.

    Parameters

    • Optionalx: number

      x value, default = 0.

    • Optionaly: number

      y value, default = 0.

    Returns b2Vec2

Properties

x: number

x value

y: number

y value

Methods

  • True if the vector 2 is valid, otherwise false. A valid vector has finite values.

    Returns boolean

    True if the vector 2 is valid, otherwise false.

  • Calculates the length of the vector 2.

    Returns number

    The length of the vector 2.

  • Calculates the length squared of the vector2.

    Returns number

    The length squared of the vector 2.

  • Calculates which vector has the maximum values and sets this vector to those values.

    Parameters

    • b: b2Vec2

      Vector 2 to compare for maximum values.

    Returns void

  • Calculates which vector has the minimum values and sets this vector to those values.

    Parameters

    • b: b2Vec2

      Vector 2 to compare for minimum values.

    Returns void

  • Vector multiplication. Stores the result in this vector 2.

    Parameters

    • a: number

      Value to multiple the vector's values by.

    Returns void

  • Sets the vector 2.

    Parameters

    • Optionalx: number

      x value, default is 0.

    • Optionaly: number

      y value, default is 0.

    Returns void

  • Subtracts the vector 2 from this vector 2. The result is stored in this vector 2.

    Parameters

    • v: b2Vec2

      Vector 2 to subtract.

    Returns void