Number2

A Number2 contains 3 number values (X & Y). It can represent different things in 2D space, like points or positions.

Constructors

A Number2 can be created,
- without parameter, equivalent to Number2(0, 0)
- with given x and y values

Functions

Returns a copy of the Number2.

local n1 = Number2(1, 0, 0)
local n2 = n1 -- n2 is not a copy but a direct reference to n1
n2.X = 10
print(n1.X) -- now n1.X == 10

-- using Copy:
local n1 = Number2(1, 0, 0)
local n2 = n1:Copy() -- n2 is a copy of n1, they're not the same Number2
n2.X = 10
print(n1.X) -- n1.X is still 1
nil Lerp ( Number2 from, Number2 to, number ratio )

Sets this Number2 to the linear interpolation between two given Number2 at a given ratio.

Normalizes the Number2 so that its magnitude becomes 1.0, and return it.

Sets this Number2's components to the given values, and return it.

Properties

Shortcut to unit vector Number2(0, -1).

This is a property of the global Number2, to be called as Number2.Down.

Same as Y property.

Shortcut to unit vector Number2(-1, 0).

This is a property of the global Number2, to be called as Number2.Left.

Magnitude of the Number2.

Shortcut to Number2(1, 1).

This is a property of the global Number2, to be called as Number2.One.

Shortcut to unit vector Number2(1, 0).

This is a property of the global Number2, to be called as Number2.Right.

Squared magnitude of the Number2.

Shortcut to unit vector Number2(0, 1).

This is a property of the global Number2, to be called as Number2.Up.

Same as X property.

X value of the Number2.

myNumber2.X = 42
print(myNumber2.X)

Y value of the Number2.

myNumber2.Y = 42
print(myNumber2.Y)

Shortcut to Number2(0, 0).

This is a property of the global Number2, to be called as Number2.Zero.