Vector2

$e. Vector2

new Vector2(x, y)

Source:
Vector2 - Creates a new 2 dimensional Vector
Parameters:
Name Type Description
x number X axis position
y number Y axis position

Methods

angle(v2) → {number}

Source:
Vector2.prototype.angle - Calculates de Angle between 2 Vector2
Parameters:
Name Type Description
v2 Vector2 The second Vector2
Returns:
The angle between the 2 bectors
Type
number

clone() → {Vector2}

Source:
Vector2.prototype.clone - returns a new Vector2
Returns:
The new copy of itself
Type
Vector2

copy(v2)

Source:
Vector2.prototype.copy - Copy a second Vector2 into the origin
Parameters:
Name Type Description
v2 Vector2 The Vector2 to be copied

cross(v2) → {number}

Source:
Vector2.prototype.cross - Calculates the Cross Vector
Parameters:
Name Type Description
v2 Vector2 The second Vector2
Returns:
The Cross Vector
Type
number

dot(v2) → {number}

Source:
Vector2.prototype.dot - Calculates the Dot Vector
Parameters:
Name Type Description
v2 Vector2 The second Vector2
Returns:
The Dot Vector
Type
number

magnitude() → {number}

Source:
Vector2.prototype.magnitude - Calculates the length of the Vector2
Returns:
returns the length of the Vector2
Type
number

multiply(mul) → {Vector2}

Source:
Vector2.prototype.multiply - Scales the Vector2 by the multiplier
Parameters:
Name Type Description
mul number The Multiplier
Returns:
Returns the new multiplied Vector2
Type
Vector2

normal(v2) → {Vector2}

Source:
Vector2.prototype.normal - Normalizes Vector2 of the substraction
Parameters:
Name Type Description
v2 Vector2 The other Vector2
Returns:
The normalized Vector2 of the substraction
Type
Vector2

normalize()

Source:
Vector2.prototype.normalize - Normalizes the Vector2 to return a Vector2 of length 1

normalized() → {Vector2}

Source:
Vector2.prototype.normalized - Normalizes the Vector2 to return a Vector2 of length 1
Returns:
returns the normalized Vector2
Type
Vector2

rotate(angle)

Source:
Vector2.prototype.rotate - Rotates the Vector2 by the angle
Parameters:
Name Type Description
angle number The angle in degreees

rrotate(angle) → {Vector2}

Source:
Vector2.prototype.rrotate - Returns a new Vector2 rotated by the angle
Parameters:
Name Type Description
angle numeric The angle in degreees
Returns:
The new Vector2 rotated
Type
Vector2

scale(mul)

Source:
Vector2.prototype.scale - Scales the Vector2 by the multiplier
Parameters:
Name Type Description
mul number The Multiplier

substract(v2) → {Vector2}

Source:
Vector2.prototype.substract - Substracts the second Vector2 from the origin
Parameters:
Name Type Description
v2 Vector2 The substractor Vector2
Returns:
Returns the new Vector2
Type
Vector2

sum(v2) → {Vector2}

Source:
Vector2.prototype.sum - Adds the second Vector2 from the origin
Parameters:
Name Type Description
v2 Vector2 The second Vector2
Returns:
Returns the new Vector2
Type
Vector2

swap()

Source:
Vector2.prototype.swap - Swtiches the X and the Y

toFixed(fix)

Source:
Vector2.prototype.toFixed - Fixes the Vector2
Parameters:
Name Type Description
fix number decimal places

toString(fixed) → {String}

Source:
Vector2.prototype.toString - Transforms Vector2 to String
Parameters:
Name Type Description
fixed Vector2 Decimals to print
Returns:
The printable string
Type
String