๐ Vector2D
A Vector2D composed of components (X, Y) with floating point precision. Used mainly for HUD and Drawing on screen
๐ Examplesโ
local new_vector = Vector2D(1452.5, 512)
๐ Constructorsโ
๐งฝ Propertiesโ
๐ฆ Functionsโ
This structure supports +, -, *, /, ==, unary - (negation) and tostring operations.
Distance: float | Distance between two points | |
DistanceSquared: float | Squared distance between two points | |
IsNear: boolean | Efficiently checks whether vector is near to another vector within a specified radius | |
Size: float | Get the length (magnitude) of this vector | |
SizeSquared: float | Get the squared length of this vector | |
Dot: float | Dot product of two vectors | |
Cross: float | Cross product of two vectors | |
Lerp: Vector2D | Linearly interpolates between this vector and another vector |
DistanceOptimalโ
Distance between two points
Returns the distance of 2 vectors
local ret = my_vector2d:Distance(other)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
other | Vector2D | The vector to get the distance to |
Returns
| Type | Beschreibung |
|---|---|
| float | The distance between the vectors |
DistanceSquaredOptimalโ
Squared distance between two points
Return the squared distance of 2 vectors
local ret = my_vector2d:DistanceSquared(other)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
other | Vector2D | The vector to get the squared distance to |
Returns
| Type | Beschreibung |
|---|---|
| float | The squared distance between the vectors |
IsNearOptimalโ
Efficiently checks whether vector is near to another vector within a specified radius
local ret = my_vector2d:IsNear(other, radius)
Returns
| Type | Beschreibung |
|---|---|
| boolean | If the vector is near to the other vector |
SizeOptimalโ
Get the length (magnitude) of this vector
local ret = my_vector2d:Size()
Returns
| Type | Beschreibung |
|---|---|
| float | The length of the vector |
SizeSquaredOptimalโ
Get the squared length of this vector
local ret = my_vector2d:SizeSquared()
Returns
| Type | Beschreibung |
|---|---|
| float | The squared length of the vector |
DotOptimalโ
Dot product of two vectors
Returns the dot product between this vector and another vector
local ret = my_vector2d:Dot(other)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
other | Vector2D | The vector to dot with |
Returns
| Type | Beschreibung |
|---|---|
| float | the dot product |
CrossOptimalโ
Cross product of two vectors
Returns the cross product between this vector and another vector, which for 2D vectors is a scalar value
local ret = my_vector2d:Cross(other)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
other | Vector2D | The vector to cross with |
Returns
| Type | Beschreibung |
|---|---|
| float | the cross product |
LerpOptimalโ
Linearly interpolates between this vector and another vector
Returns the linear interpolation between this vector and another vector by the given alpha
local ret = my_vector2d:Lerp(other, alpha)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
other | Vector2D | The vector to interpolate to |
alpha | float | The interpolation alpha, where 0 returns this vector and 1 returns the other vector |
Returns
| Type | Beschreibung |
|---|---|
| Vector2D | the interpolated vector |
