Passer au contenu principal
Version: latest - a1.156.0 ⚖️

📏 Vector2D

A Vector2D composed of components (X, Y) with floating point precision. Used mainly for HUD and Drawing on screen.


🎒 Exemples​

local new_vector = Vector2D(1452.5, 512)

🛠 Constructors​

Default Constructor​

No description provided

local my_vector2d = Vector2D(X?, Y?)

Parameters

TypeNameDefaultDescription
floatX0Coordonnée X
floatYXCoordonnée Y

🧽 Properties​

TypeNameDescription
floatXCoordonnée X
floatYCoordonnée Y

🦠 Fonctions​

info

This structure supports +, -, *, /, ==, unary - (negation) and tostring operations.

ReturnsNameDescription
floatDistanceDistance entre deux points
floatDistanceSquaredDistance au carré entre deux points
booleanIsNearEfficiently checks whether vector is near to another vector within a specified radius
floatSizeObtient la longueur (magnitude) de ce vecteur
floatSizeSquaredObtenir la longueur au carré de ce vecteur
floatDotDot product of two vectors
floatCrossCross product of two vectors
Vector2DLerpLinearly interpolates between this vector and another vector

Optimal

Distance​

Returns the distance of 2 vectors
local ret = my_vector2d:Distance(other)

Parameters

TypeParameterDefaultDescription
Vector2Dother Required parameter The vector to get the distance to

Returns

TypeDescription
floatThe distance between the vectors

Optimal

DistanceSquared​

Return the squared distance of 2 vectors
local ret = my_vector2d:DistanceSquared(other)

Parameters

TypeParameterDefaultDescription
Vector2Dother Required parameter The vector to get the squared distance to

Returns

TypeDescription
floatThe squared distance between the vectors

Optimal

IsNear​

Efficiently checks whether vector is near to another vector within a specified radius
local ret = my_vector2d:IsNear(other, radius)

Parameters

TypeParameterDefaultDescription
Vector2Dother Required parameter The vector to compare to
floatradius Required parameter The radius to check

Returns

TypeDescription
booleanIf the vector is near to the other vector

Optimal

Size​

Obtient la longueur (magnitude) de ce vecteur
local ret = my_vector2d:Size()

Returns

TypeDescription
floatThe length of the vector

Optimal

SizeSquared​

Obtenir la longueur au carré de ce vecteur
local ret = my_vector2d:SizeSquared()

Returns

TypeDescription
floatThe squared length of the vector

Optimal

Dot​

Returns the dot product between this vector and another vector
local ret = my_vector2d:Dot(other)

Parameters

TypeParameterDefaultDescription
Vector2Dother Required parameter The vector to dot with

Returns

TypeDescription
floatthe dot product

Optimal

Cross​

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

TypeParameterDefaultDescription
Vector2Dother Required parameter The vector to cross with

Returns

TypeDescription
floatthe cross product

Optimal

Lerp​

Returns the linear interpolation between this vector and another vector by the given alpha
local ret = my_vector2d:Lerp(other, alpha)

Parameters

TypeParameterDefaultDescription
Vector2Dother Required parameter The vector to interpolate to
floatalpha Required parameter The interpolation alpha, where 0 returns this vector and 1 returns the other vector

Returns

TypeDescription
Vector2Dthe interpolated vector