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

📐 Vector

A Vector composed of components (X, Y, Z) with floating point precision. Used mainly for entity position.

👐Open Source
This library implementation is Open Sourced on GitHub!
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

info

Les vecteurs sont compressés en interne et automatiquement, ce qui réduit leur taille dans le réseau jusqu'à 90 %. Des détails intéressants :

  • Les paramètres des vecteurs dans les méthodes des classes sont généralement compressés avec une précision de 1 décimale (avec quelques exceptions où nous avons besoin de plus de précision).
  • Les vecteurs transmis dans les événements distants sont compressés avec une précision de 2 décimales. If you need more precision, we recommend passing them as raw number instead.

🎒 Examples

local new_vector = Vector(1452.5, 512, 943.1)

🛠 Constructors

Default Constructor

No description provided

local my_vector = Vector(X?, Y?, Z?)
TypeNameDefaultDescription
X0X Coordinate
YXY Coordinate
ZXZ Coordinate

🧽 Properties

TypeNameDescription
XX Coordinate
YY Coordinate
ZZ Coordinate

🦠 Functions

info

This structure supports +, -, *, /, ^, ==, and tostring operations.

ReturnsNameDescription
Check against another vector for equality, within specified error limits
Distance between two points
Squared distance between two points
VectorCalculates normalized version of vector without checking for zero length
VectorGets a normalized copy of the vector, checking it is safe to do so based on the length
Checks whether vector is near to zero within a specified tolerance
Checks whether all components of the vector are exactly zero
Normalize this vector in-place if it is larger than a given tolerance. Leaves it unchanged if not
Get the length (magnitude) of this vector
Get the squared length of this vector
RotatorReturns the orientation corresponding to the direction in which the vector points

Equals

Check if the vector is equal to another vector, within specified error limits

— Returns (Are the vectors equal or not).

local ret = my_vector:Equals(other, tolerance?)
TypeParameterDefaultDescription
Vectorother Required parameter The vector to compare to
tolerance?0.000001The error limits

Distance

Returns the distance of 2 vectors

— Returns (The distance betweem the vectors).

local ret = my_vector:Distance(other)
TypeParameterDefaultDescription
Vectorother Required parameter The vector to get the distance to

DistanceSquared

Return the squared distance of 2 vectors

— Returns (The squared distance betweem the vectors).

local ret = my_vector:DistanceSquared(other)
TypeParameterDefaultDescription
Vectorother Required parameter The vector to get the squared distance to

GetUnsafeNormal

Returns the normalized version of vector without checking for zero length

— Returns Vector (The unsafe normal).

local ret = my_vector:GetUnsafeNormal()

GetSafeNormal

Returns a normalized copy of the vector, checking it is safe to do so based on the length

— Returns Vector (The safe normal).

local ret = my_vector:GetSafeNormal()

IsNearlyZero

Checks whether vector is near to zero within a specified tolerance

— Returns (If the bool is near to zero).

local ret = my_vector:IsNearlyZero(tolerance?)
TypeParameterDefaultDescription
tolerance?0.000001The error limits

IsZero

Checks whether all components of the vector are exactly zero

— Returns (If all components of the vector are exactly zero).

local ret = my_vector:IsZero()

Normalize

Normalize this vector in-place if it is larger than a given tolerance. Leaves it unchanged if not

— Returns (If the vector has been modified).

local ret = my_vector:Normalize()

Size

Get the length (magnitude) of this vector

— Returns (The lenght of the vector).

local ret = my_vector:Size()

SizeSquared

Get the squared length of this vector

— Returns (The squared length of the vector).

local ret = my_vector:SizeSquared()

Rotation

Returns the orientation corresponding to the direction in which the vector points

— Returns Rotator (The orientation of the vector).

local ret = my_vector:Rotation()