Vector2¶
Reference¶
- class Vector2¶
- module:
- x: number¶
- y: number¶
- static new(x, y)¶
Create a new Vector2
- Parameters:
x (
number
) – x componenty (
number
) – y component
- set(x, y)¶
Set values
- Parameters:
x (
number
) – x componenty (
number
) – y component
- get()¶
Get values
- Returns:
x, y component
- Return type:
array
- toData()¶
Get values of vector
- Returns:
the values
- Return type:
table
- sqrMagnitude()¶
Return the squared magnitude of the vector
- Returns:
squared magnitude
- Return type:
number
- normalized()¶
Return the normalized version of this vector
- Returns:
the normalized vector
- Return type:
- normalize()¶
Normalize the vector
- static dot(lhs, rhs)¶
Calculate dot product of 2 vectors
- static angle(from, to)¶
Calculate angle between 2 vectors
- magnitude()¶
Calculate the magnitude of the vector
- Returns:
the magnitude
- Return type:
number
- div(d)¶
Divide this vector by another one. Result is stored in this vector.
- mul(d)¶
Multiply this vector with another one. Result is stored in this vector.
- add(b)¶
Adds another vector to this vector. Result is stored in this vector