VERGELua API

Vector3

3D vector type with operators and helpers.

x:numberprop

X component.

y:numberprop

Y component.

z:numberprop

Z component.

v:Length():number

Vector length.

v:Length2D():number

Length in the X-Y plane.

v:LengthSqr():number

Squared length, avoids the square root.

v:Length2DSqr():number

Squared length in the X-Y plane.

v:Normalized():Vector3

Unit-length copy of the vector.

v:Normalize():number

Normalize in place; returns the original length.

v:Dot(v:Vector3):number

Dot product with another vector.

v:Cross(v:Vector3):Vector3

Cross product with another vector.

v:DistTo(v:Vector3):number

Distance to another vector.

v:DistTo2D(v:Vector3):number

Distance in the X-Y plane.

v:DistToSqr(v:Vector3):number

Squared distance to another vector.

v:IsZero(eps?:number):boolean

True when all components are near zero.

v:Zero()

Set all components to zero.

v:ToAngle():Vector3

Convert a direction vector to Euler angles.

v:FromAngle():Vector3

Forward direction from angle components.

v:Unpack():number, number, number

Return x, y, z as separate values.

v:Clear()

Zero the vector in place.

v:Forward():Vector3

Forward vector from this angle.

v:Right():Vector3

Right vector from this angle.

v:Up():Vector3

Up vector from this angle.

v:Vectors():Vector3, Vector3, Vector3

Forward, right and up vectors from this angle.

v:Angles():Vector3

Euler angles from a direction vector.

Vector3(x?:number, y?:number, z?:number):Vector3

Create a vector; missing args default to zero.

EulerAngles(pitch?:number, yaw?:number, roll?:number):Vector3

Create an angle vector; Forward/Right/Up/Vectors work on it.

v + v2:Vector3

Add a vector or a scalar.

v - v2:Vector3

Subtract a vector or a scalar.

v * v2:Vector3

Multiply by a vector or a scalar.

v / v2:Vector3

Divide by a vector or a scalar.

-v:Vector3

Negate all components.

v == v2:boolean

Component-wise equality.

tostring(v):string

Format as "(x, y, z)".