Skip to main content

Vector3

A 3D vector. Has built in functions for vector operations (addition, subtraction, multiplication, etc).

Fields

FieldTypeDescription
XnumberThe X component of the vector.
YnumberThe Y component of the vector.
ZnumberThe Z component of the vector.

Functions

FunctionDescription
LengthCalculates the length of a vector.
DotReturns the dot product of this vector and another.
NormalizeNormalizes the vector.
CrossReturns 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

ParameterTypeDescription
vector3Vector3The 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

ParameterTypeDescription
vector3Vector3The other vector.

Returns | Vector3

The cross product of the two vectors.

Usage

script.lua
local crossProduct = VectorA:Cross(VectorB)