Vector3
A 3D vector. Has built in functions for vector operations (addition, subtraction, multiplication, etc).
Fields
| Field | Type | Description | 
|---|---|---|
| X | number | The X component of the vector. | 
| Y | number | The Y component of the vector. | 
| Z | number | The Z component of the vector. | 
Functions
| Function | Description | 
|---|---|
| Length | Calculates the length of a vector. | 
| Dot | Returns the dot product of this vector and another. | 
| Normalize | Normalizes the vector. | 
| Cross | Returns the cross product of this vector and another. | 
Vector3:Length()
Calculates the length of a vector.
Returns | number
The length of the vector.
Usage
script.lua
local distance = (VectorA - VectorB):Length()
Vector3:Dot(vector3)
Returns the dot product of this vector and another.
Parameters
| Parameter | Type | Description | 
|---|---|---|
| vector3 | Vector3 | The other vector. | 
Returns | `number
The dot product of the two vectors.
Usage
script.lua
local dotProduct = VectorA:Dot(VectorB)
Vector3:Normalize()
Normalizes the vector.
Returns | Vector3
The normalized vector.
Usage
script.lua
local normalizedVector = VectorA:Normalize()
Vector3:Cross(vector3)
Returns the cross product of this vector and another.
Parameters
| Parameter | Type | Description | 
|---|---|---|
| vector3 | Vector3 | The other vector. | 
Returns | Vector3
The cross product of the two vectors.
Usage
script.lua
local crossProduct = VectorA:Cross(VectorB)