Type Vector2
2D Vectors for Wire I/O interop and other use cases.
Methods
| Add( vector ) | Adds the given vector to this vector, modifying this vector and returning it. |
| DistToSqr( vector ) | Returns the squared distance between the two vectors. |
| Distance( vector ) | Returns the distance between the two vectors. |
| Div( value ) | Divides the vector by the given value, modifying this vector and returning it. |
| Dot( vector ) | Returns the dot product of this vector and the given vector. |
| GetNormalized() | Returns a copy of this vector with length equal to 1, without modifying this vector. |
| IsEqualTol( otherVector, tolerance ) | Returns true if this vector is equal to the given other vector within the specified tolerance. |
| IsZero() | Returns true if the vector's components are all 0, false otherwise. |
| Length() | Returns the length of the vector. |
| LengthSqr() | Returns the squared length of the vector. |
| Mul( value ) | Multiplies the vector by the given value, modifying this vector and returning it. |
| Normalize() | Normalises the given vector's length to equal 1, modifying in-place. |
| Rotate( angleDegrees ) | Rotates the vector by the given angle in degrees around the origin, modifying in-place. |
| Set( vector ) | Sets the vector's component values to equal the given vector, modifying in-place. |
| SetUnpacked( x, y ) | Sets the vector's component values, modifying in-place. |
| Sub( vector ) | Subtracts the given vector from this vector, modifying this vector and returning it. |
| ToVector() | Returns the 2D vector as a 3D vector with its z-component set to 0. |
| Unpack() | Returns the components of the vector. |
| Zero() | Sets the components of the vector to 0. |
Methods
- Vector2:Add( vector )
-
Adds the given vector to this vector, modifying this vector and returning it.
Environment:
SharedParameters:
-
(Vector | Vector2) vector: The vector to add to this vector.
Return value:
(Vector2)This vector. -
- Vector2:DistToSqr( vector )
-
Returns the squared distance between the two vectors. This avoids the cost of a square-root.
Environment:
SharedParameters:
-
(Vector | Vector2) vector: The vector to get the squared distance from.
-
- Vector2:Distance( vector )
-
Returns the distance between the two vectors.
Environment:
SharedParameters:
-
(Vector | Vector2) vector: The vector to get the distance from.
-
- Vector2:Div( value )
-
Divides the vector by the given value, modifying this vector and returning it.
Environment:
SharedParameters:
-
(number | Vector | Vector2) value: The value to divide the vector with.
Return value:
(Vector2)This vector. -
- Vector2:Dot( vector )
-
Returns the dot product of this vector and the given vector.
Environment:
SharedParameters:
-
(Vector | Vector2) vector: The vector to take the dot product with (z-component ignored).
-
- Vector2:GetNormalized()
-
Returns a copy of this vector with length equal to 1, without modifying this vector.
Environment:
Shared - Vector2:IsEqualTol( otherVector, tolerance )
-
Returns true if this vector is equal to the given other vector within the specified tolerance.
Environment:
SharedParameters:
-
(Vector | Vector2) otherVector: The other vector to compare against (if a Vector, the z-component is ignored). -
(number) tolerance: The tolerance within which the components must be.
-
- Vector2:IsZero()
-
Returns true if the vector's components are all 0, false otherwise.
Environment:
Shared - Vector2:Length()
-
Returns the length of the vector.
Environment:
Shared - Vector2:LengthSqr()
-
Returns the squared length of the vector.
Environment:
Shared - Vector2:Mul( value )
-
Multiplies the vector by the given value, modifying this vector and returning it.
Environment:
SharedParameters:
-
(number | Vector | Vector2) value: The value to multiply the vector with.
Return value:
(Vector2)This vector. -
- Vector2:Normalize()
-
Normalises the given vector's length to equal 1, modifying in-place.
Environment:
SharedReturn value:
(Vector2)This vector. - Vector2:Rotate( angleDegrees )
-
Rotates the vector by the given angle in degrees around the origin, modifying in-place.
Environment:
SharedParameters:
-
(number) angleDegrees: The angle to rotate by (in degrees).
Return value:
(Vector2)This vector. -
- Vector2:Set( vector )
-
Sets the vector's component values to equal the given vector, modifying in-place.
Environment:
SharedParameters:
-
(Vector | Vector2) vector: The vector to copy values from.
Return value:
(Vector2)This vector. -
- Vector2:SetUnpacked( x, y )
-
Sets the vector's component values, modifying in-place.
Environment:
SharedParameters:
-
(number) x: The x-component value. -
(number) y: The y-component value.
Return value:
(Vector2)This vector. -
- Vector2:Sub( vector )
-
Subtracts the given vector from this vector, modifying this vector and returning it.
Environment:
SharedParameters:
-
(Vector | Vector2) vector: The vector to subtract from this vector.
Return value:
(Vector2)This vector. -
- Vector2:ToVector()
-
Returns the 2D vector as a 3D vector with its z-component set to 0.
Environment:
Shared - Vector2:Unpack()
-
Returns the components of the vector.
Environment:
SharedReturn values:
-
(number)The x-component of the vector. -
(number)The y-component of the vector.
-
- Vector2:Zero()
-
Sets the components of the vector to 0.
Environment:
SharedReturn value:
(Vector2)This vector.