float4represents a four-dimensional vectors.
A float4 with the magnitude of zero
A float4 with a value of 1 on every axis
Returns the length of this vector
Returns this vector with a magnitude of 1
Returns the squared length of this vector
The x-coordinate of the float4
The y-coordinate of the float4
The z-coordinate of the float4
The w-coordinate of the float4
float4 float4.New(number x, number y, number z, number w)
Constructs a new float4 using the given
Returns the distance between
local other = float4.New(1,1,1,1) local _self = float4.New(0,0,0,0) local dist = float4.Distance(other, _self) print("distance to other: " .. dist)
Dot product of two vectors.
Linearly interpolates between two points. Interpolates between the points
t. The parameter
tis clamped to the range [0, 1]. When
t= 0, returns
t= 1, returns
t= 0.5, returns the midpoint of between
aStart value, returned when t = 0.
bEnd value, returned when t = 1.
Returns a vector that is made from the largest components of two vectors.
local a = float4.New(1,2,3,4) local b = float4.New(4,3,2,1) -- (4,3,3,4) print(float4.Max(a,b))
Returns a vector that is made from the smallest components of two vectors.
Moves a point
currentThe position to move from.
targetThe position to move towards.
maxDistanceDeltaDistance to move
Projects a vector onto another vector.
Multiplies two vectors component-wise. Every component in the result is a component of
amultiplied by the same component of
float4 Mul(number value)
Multiplies self by a number, same as operator
local vector = float4.New(1,1,1,1) -- same as result = vector * 2 local result = vector:Mul(2) -- (2,2,2,2) print(result)
float4 Div(number value)
Divides self by a number, same as operator
Adds other vector, same as operator
Subtracts self from another, same as operator
Returns the squared length of this vector.
Returns the length of this vector. The length of the vector is square root of
Makes this vector have a magnitude of 1.
void Set(number x, number y, number z, number w)
wcomponents of an existing float4.
Makes and returns this vector have a magnitude of 1.
void SetScale(float4 value)
Multiplies two vectors component-wise.