User Tools

Site Tools


wiki:vector2

Vector2

Vector2 is a global meta-table composed of 2 numbers (Its data) and some functions to manipulate these data.

Data

  • x: number
  • y: number

Functions

Operators

  • __unm(Vector2)
  • __add(Vector2, Vector2)
  • __sub(Vector2, Vector2)
  • __mul(Vector2, number)
  • __div(Vector2, number)
  • __tostring(Vector2)

new()

  • Description: Create an instance of Vector2 with x and y equals to zero
  • Signature: (): Vector2

new(number, number)

  • Description: Create an instance of Vector2 with the given values
  • Signature: (x: number, y: number): Vector2

One()

  • Description: Returns a (1,1) Vector2
  • Signature: (): Vector2

Zero()

  • Description: Returns a (0,0) Vector2
  • Signature: (): Vector2

Length(Vector2)

  • Description: Returns the length of the given Vector2
  • Signature: (target: Vector2): number

Normalize(Vector2)

  • Description: Returns the normalized version of the given Vector2
  • Signature: (target: Vector2): number

Dot(Vector2, Vector2)

  • Description: Returns the dot product of the two given Vector2
  • Signature: (left: Vector2, right: Vector2): number

Lerp(Vector2, Vector2, number)

  • Description: Calculate the linear interpolation between two Vector2 using the given alpha
  • Signature: (start: Vector2, end: Vector2, alpha: number): Vector2

AngleBetween(Vector2, Vector2)

  • Description: Calculate the angle between two Vector2
  • Signature: (left: Vector2, right: Vector2): number
wiki/vector2.txt · Last modified: 2019/05/07 17:45 (external edit)