Class Vector2
Version added: before 9.5
The Vector2 class is used to represent a 2D vector or point.
If necessary, instances of this class can be created by:
- Local variable:
- Global (see Script Structure about conventions for naming globals):
If necessary, instances of this class can be created by:
- Local variable:
local vec2 = LM.Vector2:new_local()
- Global (see Script Structure about conventions for naming globals):
XX_vec2 = LM.Vector2:new()
Methods of Vector2:
Name | Returns | Description | Ver |
Cross Cross(vec2) | Vector3 | Added in version 11.1 | 11.1 |
Dot Dot(vec2) | real | Computes the dot product of this vector and a second one | < 9.5 |
GetOrthogonal GetOrthogonal() | Vector2 | Returns a vector that points 90 degrees away from the orignal vector | < 9.5 |
Mag Mag() | real | Computes the magnitude of a vector | < 9.5 |
Norm Norm() | Vector2 | Returns a normalized copy of the vector | < 9.5 |
NormMe NormMe() | void | Normalizes a vector | < 9.5 |
operator‑ operator-(vec2) | Vector2 | Subtracts one vector from another and returns the result as a new vector | < 9.5 |
operator* operator*(f) | Vector2 | Multiplies a vector by a number, returning the result as a new vector | < 9.5 |
operator+ operator+(vec2) | Vector2 | Adds two vectors and returns the result as a new vector | < 9.5 |
operator/ operator/(f) | Vector2 | Divides a vector by a number, returning the result as a new vector | < 9.5 |
Rotate Rotate(angle) | void | Rotates the vector by the specified angle | < 9.5 |
Set Set(vx, vy) | void | Set the value of a vector | < 9.5 |
Set Set(vec2) | void | Set the value of a vector | < 9.5 |
SquaredMag SquaredMag() | real | Computes the squared magnitude of a vector | < 9.5 |
Properties of Vector2:
Name | Type | Description | Ver |
x | real | The x (or horizontal) coordinate of the vector. | < 9.5 |
y | real | The y (or vertical) coordinate of the vector. | < 9.5 |