Vector2
Vector2
In Roblox, the Vector2 datatype is often used in working with GUI elements and 2D mouse positions.
Constructors
| Vector2.new ( number x, number y ) |
|
Returns a Vector2 from the given x and y components. |
Properties
| Vector2 Vector2.zero |
|
A Vector2 with a magnitude of zero. This API member is a constant, and must be accessed through the print(Vector2.zero) --> 0, 0 |
| Vector2 Vector2.one |
|
A Vector2 with a value of 1 on every axis. This API member is a constant, and must be accessed through the print(Vector2.one) --> 1, 1 |
| Vector2 Vector2.xAxis |
|
A Vector2 with a value of 1 on the X axis. This API member is a constant, and must be accessed through the print(Vector2.xAxis) --> 1, 0 |
| Vector2 Vector2.yAxis |
|
A Vector2 with a value of 1 on the Y axis. This API member is a constant, and must be accessed through the print(Vector2.yAxis) --> 0, 1 |
| number Vector2.X |
|
The x-coordinate of the Vector2. |
| number Vector2.Y |
|
The y-coordinate of the Vector2. |
| number Vector2.Magnitude |
|
The length of the vector. |
| Vector2 Vector2.Unit |
|
A normalized copy of the vector. |
Functions
| number Vector2:Cross ( Vector2 other ) |
|
Returns the cross product of the two vectors. |
| number Vector2:Dot ( Vector2 v ) |
|
Returns a scalar dot product of the two vectors. |
| Vector2 Vector2:Lerp ( Vector2 v, number alpha ) |
|
Returns a Vector2 linearly interpolated between this Vector2 and v by the fraction alpha |
| Vector2 Vector2:Max ( Tuple others... ) |
|
Returns a local a = Vector2.new(1, 2) local b = Vector2.new(2, 1) print(a:Max(b)) -- Vector2.new(2, 2) |
| Vector2 Vector2:Min ( Tuple others... ) |
|
Returns a local a = Vector2.new(1, 2) local b = Vector2.new(2, 1) print(a:Min(b)) -- Vector2.new(1, 1) |
Math Operations
| Vector2 Vector2 + Vector2 |
|
Returns a new Vector2 with each component of the second added to the corresponding component of the first. |
| Vector2 Vector2 - Vector2 |
|
Returns a new Vector2 with each component of the second subtracted from the corresponding component of the first. |
| Vector2 Vector2 * Vector2 |
|
Returns a new Vector2 with each component of the second multiplied the corresponding component of the first. |
| Vector2 Vector2 / Vector2 |
|
Returns a new Vector2 with each component of the first divided by the corresponding component of the second. |
| Vector2 Vector2 * number |
|
Returns the Vector2 with each component multiplied by the number. |
| Vector2 Vector2 / number |
|
Returns the Vector2 with each component divided by the number. |