float2¶
float2 describes a vector in 2D spaces.
It contains functions for doing common vector operations.Properties¶
float2 zero¶
A float2 with the magnitude of zero
float2 one¶
A float2 with a value of 1 on every axis
float2 up¶
A float2 with a value of 1 on the Y axis
float2 down¶
A float2 with a value of -1 on the Y axis
float2 right¶
A float2 with a value of 1 on the X axis
float2 left¶
A float2 with a value of -1 on the X axis
number magnitude¶
Returns the length of this vector
float2 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 float2
number y¶
The y-coordinate of the float2
Functions¶
float2 float2.New(number x, number y)¶
Constructs a new float2 using the given 
x, and y components.
number float2.Angle(float2 from, float2 to)¶
ReturnsThe angle in degrees between the two vectors.
Gets the unsigned angle in degrees between from and to.
The angle returned is the unsigned angle between the two vectors.
fromThe vector from which the angular difference is measured.toThe vector to which the angular difference is measured.
float2 float2.ClampMagnitude(float2 value, number maxLength)¶
Returns a copy of 
value with its magnitude clamped to maxLength.
number float2.Distance(float2 a, float2 b)¶
Returns the distance between 
a and b.
1 2 3 4  |  | 
number float2.Dot(float2 a, float2 b)¶
Returns dot Product of two vectors.
float2 float2.Lerp(float2 a, float2 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.
aStart value, returned when t = 0.bEnd value, returned when t = 1.
float2 float2.LerpUnclamped(float2 a, float2 b, number t)¶
Linearly interpolates between vectors 
a and b by t.
When t = 0, returns a.
When t = 1, returns b.
When t = 0.5, returns the midpoint of between a and b.
float2 float2.Max(float2 a, float2 b)¶
Returns a vector that is made from the largest components of two vectors.
1 2 3 4  |  | 
float2 float2.Min(float2 a, float2 b)¶
Returns a vector that is made from the smallest components of two vectors.
float2 float2.MoveTowards(float2 current, float2 target, number maxDistanceDelta)¶
Moves a point 
current towards target.
currentThe position to move from.targetThe position to move towards.maxDistanceDeltaDistance to movecurrent per call.
float2 float2.Normalize(float2 value)¶
Makes vector have a magnitude of 1.
When normalized, a vector keeps the same direction but its length is 1.0.
float2 float2.Reflect(float2 inDirection, float2 inNormal)¶
Reflects a vector off the plane defined by a normal.
float2 float2.Scale(float2 a, float2 b)¶
Multiplies two vectors component-wise.
Every component in the result is a component of 
a multiplied by the same component of b.
float2 Mul(number value)¶
ReturnsSelf.
Multiplies self by a number. Mul will modify the value of self. Instead, apply operator * to create a new float2 value without self modification.
valueA number.
1 2 3 4 5 6 7 8  |  | 
In this example, Mul modifies the value of a to [2,2], while b*2 creates a new float2 without modifying b.
float2 Div(number value)¶
ReturnsSelf.
Divides self by a number. Div will modify the value of self. Instead, apply operator / to create a new float2 value without self modification.
valueA number.
float2 Add(float2 value)¶
ReturnsSelf.
Adds a float2 to self. Add will modify the value of self. Instead, apply operator + to create a new float2 value without modification.
valueA float2 value.
1 2 3 4 5 6 7 8 9 10  |  | 
In this example, function Add modifies the value of a to [4, 6], while b+c creates a new float2 without modification.
float2 Sub(float2 value)¶
ReturnsSelf.
Subtracts a float2 from self. Sub will modify the value of self. Instead, apply operator - to create a new float2 value without modification.
valueA float2.
number SqrMagnitude()¶
Returns the squared length of this vector.
float2 Clone()¶
Returns a deep copy of this vector.
float2 Magnitude()¶
Returns the length of this vector.
The length of the vector is square root of 
(x*x+y*y).
void Set(number x, number y)¶
Set 
x and y components of an existing float2.
float2 SetNormalize()¶
Makes this vector have a magnitude of 1.