Lua API
On this page

Vector4

Tip

This is a builtin dotnet type. The documentation and api interface are generated from dotnet source files.

Represents a vector with four single-precision floating-point values.

Fields:

One Vector4

staticread only

Gets a vector whose 4 elements are equal to one.

UnitW Vector4

staticread only

Gets the vector (0,0,0,1).

UnitX Vector4

staticread only

Gets the vector (1,0,0,0).

UnitY Vector4

staticread only

Gets the vector (0,1,0,0).

UnitZ Vector4

staticread only

Gets the vector (0,0,1,0).

W number

The W component of the vector.

X number

The X component of the vector.

Y number

The Y component of the vector.

Z number

The Z component of the vector.

Zero Vector4

staticread only

Gets a vector whose 4 elements are equal to zero.

Constructors:

New(value: number) :

Creates a new Vector4 object whose four elements have the same value.

Parameters:
NameTypeDefaultSummary
valuenumber

The value to assign to all four elements.

New(value: Vector3, w: number) :

Constructs a new Vector4 object from the specified Vector3 object and a W component.

Parameters:
NameTypeDefaultSummary
valueVector3

The vector to use for the X, Y, and Z components.

wnumber

The W component.

New(value: Vector2, z: number, w: number) :

Creates a new Vector4 object from the specified Vector2 object and a Z and a W component.

Parameters:
NameTypeDefaultSummary
valueVector2

The vector to use for the X and Y components.

znumber

The Z component.

wnumber

The W component.

New(x: number, y: number, z: number, w: number) :

Creates a vector whose elements have the specified values.

Parameters:
NameTypeDefaultSummary
xnumber

The value to assign to the Vector4.X field.

ynumber

The value to assign to the Vector4.Y field.

znumber

The value to assign to the Vector4.Z field.

wnumber

The value to assign to the Vector4.W field.

Methods:

Abs(value: Vector4) : Vector4

static

Returns a vector whose elements are the absolute values of each of the specified vector's elements.

Parameters:
NameTypeDefaultSummary
valueVector4

A vector.

Returns:Vector4

Add(left: Vector4, right: Vector4) : Vector4

static

Adds two vectors together.

Parameters:
NameTypeDefaultSummary
leftVector4

The first vector to add.

rightVector4

The second vector to add.

Returns:Vector4

Clamp(value1: Vector4, min: Vector4, max: Vector4) : Vector4

static

Restricts a vector between a minimum and a maximum value.

Parameters:
NameTypeDefaultSummary
value1Vector4

The vector to restrict.

minVector4

The minimum value.

maxVector4

The maximum value.

Returns:Vector4

CopyTo(array: number, index: number) : nil

Copies the elements of the vector to a specified array starting at a specified index position.

Parameters:
NameTypeDefaultSummary
arraynumber

The destination array.

indexnumber

The index at which to copy the first element of the vector.

Returns:nil

CopyTo(array: number) : nil

Copies the elements of the vector to a specified array.

Parameters:
NameTypeDefaultSummary
arraynumber

The destination array.

Returns:nil

Distance(value1,value2) value1 Vector4 , value2 Vector4

DistanceSquared(value1,value2) value1 Vector4 , value2 Vector4

Divide(left,divisor) left Vector4 , divisor number

Divide(left,right) left Vector4 , right Vector4

Dot(vector1,vector2) vector1 Vector4 , vector2 Vector4

Length()

LengthSquared()

Lerp(value1,value2,amount) value1 Vector4 , value2 Vector4 , amount number

Max(value1,value2) value1 Vector4 , value2 Vector4

Min(value1,value2) value1 Vector4 , value2 Vector4

Multiply(left,right) left Vector4 , right Vector4

Multiply(left,right) left Vector4 , right number

Multiply(left,right) left number , right Vector4

Negate(value) value Vector4

Normalize(vector) vector Vector4

SquareRoot(value) value Vector4

Subtract(left,right) left Vector4 , right Vector4

ToString()

ToString(format) format string

Transform(position,matrix) position Vector3 , matrix Matrix4x4

Transform(position,matrix) position Vector2 , matrix Matrix4x4

Transform(value,rotation) value Vector2 , rotation Quaternion

Transform(value,rotation) value Vector3 , rotation Quaternion

Transform(value,rotation) value Vector4 , rotation Quaternion

Transform(vector,matrix) vector Vector4 , matrix Matrix4x4