Vec2

A two dimensional vector.

Properties

  • x - double

  • y - double

Methods

Vec2:new(x, y)

  • x - What to set x to

  • y - What to set y to

Constructs a new Vec2 with the provided x and y.

Example:

length()

Returns the length of the Vec2

Example:

distanceTo(otherVec2)

  • otherVec2 - A different Vec2

Returns the distance from this vector to the otherVec2

Example:

angleTo(otherVec2)

  • otherVec2 - A different Vec2

Returns the angle to the otherVec2

Example:

normalized()

Returns this vector but normalized (that is with length 1)

Example:

scale(scalar)

  • scalar - By how much you want to scale the vector

Returns a scaled version of this vector

Example:

toString()

Returns a string representation of the Vec2

Example:

Last updated