API Docs for:
Show:

Vector2D Class

2D vector object with support functions for performing vector arithmetic.

Constructor

Vector2D

()

Methods

add

(
  • vector2D
)
Vector2D

Adds the specified vector to this vector.

Parameters:

Returns:

Vector2D: Returns this vector, allowing for operator chaining.

added

(
  • vector2D
  • output
)
Vector2D

Adds the specified vector to this vector and stores the result in the output vector. Doesn't modify this vector.

Parameters:

  • vector2D Vector2D

    Vector to be added.

  • output Vector2D

    Vector that will hold the result.

Returns:

Vector2D: Returns the output vector, allowing for operator chaining.

divide

(
  • value
)
Vector2D

Divides this vector by the value.

Parameters:

  • value Number

Returns:

Vector2D: Returns this vector, allowing for operator chaining.

divided

(
  • value
  • output
)
Vector2D

Divides this vector by the value and stores the result in the output vector. Doesn't modify this vector.

Parameters:

  • value Number
  • output Vector2D

    Vector that will hold the result.

Returns:

Vector2D: Returns the output vector, allowing for operator chaining.

dot

(
  • vector2D
)
Number

Parameters:

  • vector2D Vector2D

    The other vector the dot product will be performed with.

Returns:

Number: The dot product for this and the specified vector.

invert

() Vector2D

Inverts this vector.

Returns:

Vector2D: Returns this vector, allowing for operator chaining.

inverted

(
  • output
)
Vector2D

Inverts this vector and stores the result in the output vector. Doesn't modify this vector.

Parameters:

  • output Vector2D

    Vector that will hold the result.

Returns:

Vector2D: Returns the output vector, allowing for operator chaining.

magnitude

() Number

Returns:

Number: The magnitude of this vector.

magnitudeSquared

() Number

Returns:

Number: The squared magnitude of this vector.

multiplied

(
  • value
  • output
)
Vector2D

Multiplies this vector by the value and stores the result in the output vector. Doesn't modify this vector.

Parameters:

  • value Number
  • output Vector2D

    Vector that will hold the result.

Returns:

Vector2D: Returns the output vector, allowing for operator chaining.

multiply

(
  • value
)
Vector2D

Multiplies this vector by the value.

Parameters:

  • value Number

Returns:

Vector2D: Returns this vector, allowing for operator chaining.

normalize

() Vector2D

Normalizes this vector.

Returns:

Vector2D: Returns this vector, allowing for operator chaining.

normalized

(
  • output
)
Vector2D

Normalizes this vector and stores the result in the output vector. Doesn't modify this vector.

Parameters:

  • output Vector2D

    Vector that will hold the result.

Returns:

Vector2D: Returns the output vector, allowing for operator chaining.

subtract

(
  • vector2D
)
Vector2D

Subtracts the specified vector from this vector.

Parameters:

  • vector2D Vector2D

    Vector to be subtracted.

Returns:

Vector2D: Returns this vector, allowing for operator chaining.

subtracted

(
  • vector2D
  • output
)
Vector2D

Subtracts the specified vector from this vector and stores the result in the output vector. Doesn't modify this vector.

Parameters:

  • vector2D Vector2D

    Vector to be subtracted.

  • output Vector2D

    Vector that will hold the result.

Returns:

Vector2D: Returns the output vector, allowing for operator chaining.