Home

Vector2

2D floating-point vector

Operations

New

Creates a new vector

New()

Creates a new vector

New(x:Float, y:Float)
Parameters
NameTypeDescription
xFloatx-position
yFloaty-position

Add

Adds to current vector

method : public : Add(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2vector to add

Add two vectors

function : public : Add(lhs:Vector2, rhs:Vector2) ~ Vector2
Parameters
NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return
TypeDescription
Vector2new vector

AddX

Increments the current x-position

method : public : AddX(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2increment to the current x-position

Increments the current x-position

method : public : AddX(x:Int) ~ Nil
Parameters
NameTypeDescription
xIntincrement to the current x-position

AddY

Increments the current y-position

method : public : AddY(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2increment to the current y-position

Increments the current y-position

method : public : AddY(y:Int) ~ Nil
Parameters
NameTypeDescription
yIntincrement to the current y-position

Div

Divides current vector

method : public : Div(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2vector to divide

Divides current vector

method : public : Div(v:Float) ~ Nil
Parameters
NameTypeDescription
vFloatv to divide by

Divides two vectors

function : public : Div(lhs:Vector2, rhs:Vector2) ~ Vector2
Parameters
NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return
TypeDescription
Vector2new vector

Divides a vector by a value

function : public : Div(rhs:Vector2, v:Float) ~ Vector2
Parameters
NameTypeDescription
rhsVector2vector
vFloatvalue to divides by

Return
TypeDescription
Vector2new vector

DivX

Divides the current x-position

method : public : DivX(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2value to divide by the current x-position

Divides the current x-position

method : public : DivX(x:Int) ~ Nil
Parameters
NameTypeDescription
xIntvalue to divide by the current x-position

Divides x-vector component by a value

function : public : DivX(rhs:Vector2, v:Float) ~ Vector2
Parameters
NameTypeDescription
rhsVector2vector
vFloatvalue to multiple by

Return
TypeDescription
Vector2new vector

DivY

Divides the current y-position

method : public : DivY(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2value to divide by the current y-position

Divides the current y-position

method : public : DivY(y:Int) ~ Nil
Parameters
NameTypeDescription
yIntvalue to divide by the current y-position

Divides y-vector component by a value

function : public : DivY(rhs:Vector2, v:Float) ~ Vector2
Parameters
NameTypeDescription
rhsVector2vector
vFloatvalue to divide by

Return
TypeDescription
Vector2new vector

Dot

Calculates the dot product

function : public : Dot(lhs:Vector2, rhs:Vector2) ~ Float
Parameters
NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return
TypeDescription
Floatdot product

GetX

Gets the x-position

method : public : GetX() ~ Float
Return
TypeDescription
Floatx-position

GetY

Gets the y-position

method : public : GetY() ~ Float
Return
TypeDescription
Floaty-position

Limit

Sets vector limit

method : public : Limit(v:Float) ~ Nil
Parameters
NameTypeDescription
vFloatlimit

Sets vector limit

method : public : Limit(x:Float, y:Float) ~ Nil
Parameters
NameTypeDescription
xFloatx-limit
yFloaty-limit

Magnitude

Calculates the magnitude

method : public : Magnitude() ~ Float
Return
TypeDescription
Floatmagnitude

MagnitudeSquared

Calculates the magnitude squared

method : public : MagnitudeSquared() ~ Float
Return
TypeDescription
Floatmagnitude squared

Mul

Multiples current vector

method : public : Mul(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2vector to multiply

Multiples current vector

method : public : Mul(v:Float) ~ Nil
Parameters
NameTypeDescription
vFloatv to multiply by

Multiplies two vectors

function : public : Mul(lhs:Vector2, rhs:Vector2) ~ Vector2
Parameters
NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return
TypeDescription
Vector2new vector

Multiplies a vector by a value

function : public : Mul(rhs:Vector2, v:Float) ~ Vector2
Parameters
NameTypeDescription
rhsVector2vector
vFloatvalue to multiple by

Return
TypeDescription
Vector2new vector

MulX

Multiplies the current x-position

method : public : MulX(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2value to multiply to the current x-position

Multiplies the current x-position

method : public : MulX(x:Int) ~ Nil
Parameters
NameTypeDescription
xIntvalue to multiply to the current x-position

Multiplies x-vector component by a value

function : public : MulX(rhs:Vector2, v:Float) ~ Vector2
Parameters
NameTypeDescription
rhsVector2vector
vFloatvalue to multiple by

Return
TypeDescription
Vector2new vector

MulY

Multiplies the current y-position

method : public : MulY(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2value to multiply to the current y-position

Multiplies the current y-position

method : public : MulY(y:Int) ~ Nil
Parameters
NameTypeDescription
yIntvalue to multiply to the current y-position

Multiplies y-vector component by a value

function : public : MulY(rhs:Vector2, v:Float) ~ Vector2
Parameters
NameTypeDescription
rhsVector2vector
vFloatvalue to multiply by

Return
TypeDescription
Vector2new vector

Normalize

Normalizes a unit vector

method : public : Normalize() ~ Nil

Set

Sets the x and y positions

method : public : Set(x:Float, y:Float) ~ Nil
Parameters
NameTypeDescription
xFloatx-position
yFloaty-position

SetX

Sets the x-position

method : public : SetX(x:Float) ~ Nil
Parameters
NameTypeDescription
xFloatx-position

SetY

Sets the y-position

method : public : SetY(y:Float) ~ Nil
Parameters
NameTypeDescription
yFloaty-position

Sub

Subtracts from current vector

method : public : Sub(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2vector to subtract

Subtract two vectors

function : public : Sub(lhs:Vector2, rhs:Vector2) ~ Vector2
Parameters
NameTypeDescription
lhsVector2left vector
rhsVector2right vector

Return
TypeDescription
Vector2new vector

SubX

Decrements the current x-position

method : public : SubX(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2decrements to the current x-position

Decrements the current x-position

method : public : SubX(x:Int) ~ Nil
Parameters
NameTypeDescription
xIntdecrements to the current x-position

SubY

Decrements the current y-position

method : public : SubY(rhs:Vector2) ~ Nil
Parameters
NameTypeDescription
rhsVector2decrements to the current y-position

Decrements the current y-position

method : public : SubY(y:Int) ~ Nil
Parameters
NameTypeDescription
yIntdecrements to the current y-position

ToString

String representation of vector

method : public : ToString() ~ String
Return
TypeDescription
Stringstring representation

Zero

Sets vector to zero

method : public : Zero() ~ Nil