# float4¶

`float4` represents a four-dimensional vectors.

### Properties¶

#### float4 zero¶

A float4 with the magnitude of zero

#### float4 one¶

A float4 with a value of 1 on every axis

#### number magnitude¶

Returns the length of this vector

#### float4 normalized¶

Returns this vector with a magnitude of 1

#### number sqrMagnitude¶

Returns the squared length of this vector

#### number x¶

The x-coordinate of the float4

#### number y¶

The y-coordinate of the float4

#### number z¶

The z-coordinate of the float4

#### number w¶

The w-coordinate of the float4

### Functions¶

#### float4 float4.New(number x, number y, number z, number w)¶

Constructs a new float4 using the given `x`, `y`,`z` and `w` components.

#### number float4.Distance(float4 a, float4 b)¶

Returns the distance between `a` and `b`.
 ```1 2 3 4``` ``````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) ``````

#### number float4.Dot(float4 a, float4 b)¶

Dot product of two vectors.

#### float4 float4.Lerp(float4 a, float4 b, number t)¶

Linearly interpolates between two points. Interpolates between the points `a` and `b` by `t`. The parameter `t` is clamped to the range [0, 1]. When `t` = 0, returns `a`. When `t` = 1, returns `b`. When `t` = 0.5, returns the midpoint of between `a` and `b`.
• `a` Start value, returned when t = 0.
• `b` End value, returned when t = 1.

#### float4 float4.Max(float4 a, float4 b)¶

Returns a vector that is made from the largest components of two vectors.
 ```1 2 3 4``` ``````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)) ``````

#### float4 float4.Min(float4 a, float4 b)¶

Returns a vector that is made from the smallest components of two vectors.

#### float4 float4.MoveTowards(float4 current, float4 target, number maxDistanceDelta)¶

Moves a point `current` towards `target`.
• `current` The position to move from.
• `target` The position to move towards.
• `maxDistanceDelta` Distance to move current per call.

#### float4 float4.Project(float4 a, float4 b)¶

Projects a vector onto another vector.

#### float4 float4.Scale(float4 a, float4 b)¶

Multiplies two vectors component-wise. Every component in the result is a component of `a` multiplied by the same component of `b`.

#### float4 Mul(number value)¶

ReturnsSelf.
Multiplies self by a number. Mul will modify the value of self. Instead, apply operator `*` to create a new float4 value without self modification.
• `value` A number.
 ```1 2 3 4 5 6 7 8``` ``````local a = float4.New(1,1,1,1) a:Mul(2) print(tostring(a)) -- output: [2,2,2,2] local b = float4.New(3, 5, 7, 9) local c = b * 2 print(tostring(b)) -- output: [3,5,7,9] print(tostring(c)) -- output: [6,10,14,18] ``````

In this example, `Mul` modifies the value of `a` to [2,2,2,2], while `b*2` creates a new float4 without modifying `b`.

#### float4 Div(number value)¶

ReturnsSelf.
Divides self by a number. Div will modify the value of self. Instead, apply operator `/` to create a new float4 value without self modification.
• `value` A number.

ReturnsSelf.
Adds a float4 to self. `Add` will modify the value of self. Instead, apply operator `+` to create a new float4 value without modification.
• `value` A float4 value.
 ``` 1 2 3 4 5 6 7 8 9 10``` ``````local a = float4.New(1, 2, 3, 4) a:Add(float4.New(5, 6, 7, 8)) print(tostring(a)) -- output: [6,8,10,12] local b = float4.New(8, 10, 12, 14) local c = float4.New(9, 11, 13, 15) local d = b+c print(tostring(b)) -- output: [8,10,12,14] print(tostring(c)) -- output: [9,11,13,15] print(tostring(d)) -- output: [17,21,25,29] ``````

In this example, function `Add` modifies the value of a to [6,8,10,12], while `b+c` creates a new float4 without modification.

#### float4 Sub(float4 value)¶

ReturnsSelf.
Subtracts a float4 from self. `Sub` will modify the value of self. Instead, apply operator `-` to create a new float4 value without modification.
• `value` A float4.

#### number SqrMagnitude()¶

Returns the squared length of this vector.

#### number Magnitude()¶

Returns the length of this vector. The length of the vector is square root of `(x*x+y*y)`.

#### float4 Normalize()¶

Makes this vector have a magnitude of 1.

#### void Set(number x, number y, number z, number w)¶

Set `x`, `y`, `z` and `w` components of an existing float4.

#### float4 SetNormalize()¶

Makes and returns this vector have a magnitude of 1.

#### void SetScale(float4 value)¶

Multiplies two vectors component-wise.