Class: Vector2d

Utils.Vector2d

the vector handling class

new Utils.Vector2d (x, y)

Name Type Description
x Number the x coordinate (defaults to 0)
y Number the y coordinate (defaults to 0)

Methods

add (ax, ay)Utils.Vector2d

adds by scalars
Name Type Description
ax Number scalar to add to x component
ay Number scalar to add to y component
Returns:
Type Description
Utils.Vector2d the updated vector

addVector (vec)Utils.Vector2d

adds another vector
Name Type Description
vec Utils.Vector2d vector to add to this vector
Returns:
Type Description
Utils.Vector2d the updated vector

clone ()Utils.Vector2d

clones the vector
Returns:
Type Description
Utils.Vector2d copy of the vector

dotProduct (vec)Number

dot product by another vector
Name Type Description
vec Vector2d another vector to dot product by
Returns:
Type Description
Number the dot product

getNormal ()Utils.Vector2d

gets the normalized vector as new vector
Returns:
Type Description
Utils.Vector2d the normalized vector

length ()Number

get the length of this vector
Returns:
Type Description
Number the length of the vector

makeArray ()Array

converts the vector to an array of components
Returns:
Type Description
Array array of the vector's components

normalize ()

normalize the vector

scalarAdd (d)Utils.Vector2d

adds a scalar to both components.
Name Type Description
d Number scalar to add
Returns:
Type Description
Utils.Vector2d the updated vector

scalarDiv (scalar)Utils.Vector2d

divides by scalar
Name Type Description
scalar Number scalar to divide by
Returns:
Type Description
Utils.Vector2d the updated vector

scalarMul (scalar)Utils.Vector2d

multiplies by scalar
Name Type Description
scalar Number scalar to multiply by
Returns:
Type Description
Utils.Vector2d the updated vector

scalarSub (d)Utils.Vector2d

subtracts a scalar to both components.
Name Type Description
d Number scalar to subtract
Returns:
Type Description
Utils.Vector2d the updated vector

sub (ax, ay)Utils.Vector2d

subs by scalars
Name Type Description
ax Number scalar to sub to x component
ay Number scalar to sub to y component
Returns:
Type Description
Utils.Vector2d the updated vector

subVector (vec)Utils.Vector2d

subtracts another vector
Name Type Description
vec Utils.Vector2d vector to sub from this vector
Returns:
Type Description
Utils.Vector2d the updated vector