Skip to content

Class: Vector2f

Methods

NameDescription
:__add(other)Vector addition by an another vector or number
:__div(other)Vector division by an another vector or number
:__eq(other)Equality comparison
:__len()Number of dimensions/elements in the vector, not the length of the vector
:__mul(other)Vector multplication by an another vector or number
:__sub(other)Vector subtraction by an another vector or number
:__tostring()Format the vector into a human readable string
:__unm()Unary minus of the vector
:length()Get the length of the vector

Fields

NameTypeDescription
xnumber
ynumber

Method declarations

Method: __add

Vector addition by an another vector or number

lua
function Vector2f:__add(
    other
) end

Parameters:

  • other (number|Vector2f) - An another vector or number to add

Returns:

  • Vector2f - A new vector that is a product of addition

Method: __div

Vector division by an another vector or number

lua
function Vector2f:__div(
    other
) end

Parameters:

  • other (number|Vector2f) - An another vector or number to divide with

Returns:

  • Vector2f - A new vector that is a product of division

Method: __eq

Equality comparison

lua
function Vector2f:__eq(
    other
) end

Parameters:

  • other (Vector2f) - An another vector to compare with

Returns:

  • boolean - True if this and the other vector equal

Method: __len

Number of dimensions/elements in the vector, not the length of the vector

lua
function Vector2f:__len() end

Returns:

  • integer - The number of dimensions in the vector (i.e. 2)

Method: __mul

Vector multplication by an another vector or number

lua
function Vector2f:__mul(
    other
) end

Parameters:

  • other (number|Vector2f) - An another vector or number to multiply with

Returns:

  • Vector2f - A new vector that is a product of multplication

Method: __sub

Vector subtraction by an another vector or number

lua
function Vector2f:__sub(
    other
) end

Parameters:

  • other (number|Vector2f) - An another vector or number to subtract

Returns:

  • Vector2f - A new vector that is a product of subtractino

Method: __tostring

Format the vector into a human readable string

lua
function Vector2f:__tostring() end

Returns:

  • string - A string representation of this vector

Method: __unm

Unary minus of the vector

lua
function Vector2f:__unm() end

Returns:

  • Vector2f - The negative of the current vector

Method: length

Get the length of the vector

lua
function Vector2f:length() end

Returns:

  • number - The length of the vector

Field declarations

Field: x

Type: number

Field: y

Type: number