Class: Vector

algo.layout. Vector

new Vector(x, y)

basic vector class, not to be confused with a line which is not necessarily anchored at the origin
Parameters:
Name Type Description
x
y
Source:

Methods

<static> random() → {algo.layout.Vector}

make a random vector between -0.5 and + 0.5
Source:
Returns:
Type
algo.layout.Vector

add(v2) → {algo.layout.Vector}

add v2 and return a new vector
Parameters:
Name Type Description
v2
Source:
Returns:
Type
algo.layout.Vector

angle(other) → {number}

get the angle between this Vector and another in degrees
Parameters:
Name Type Description
other algo.layout.Vector
Source:
Returns:
polar angle between two points in degrees
Type
number

clone() → {algo.layout.Vector}

clone into new Vector
Source:
Returns:
Type
algo.layout.Vector

divide(n) → {algo.layout.Vector}

divide self by n and return a new vector
Parameters:
Name Type Description
n
Source:
Returns:
Type
algo.layout.Vector

lerp(that, t) → {algo.layout.Vector}

return a new vector that is lerped toward that by the parametric value t
Parameters:
Name Type Description
that algo.layout.Vector
t number
Source:
Returns:
Type
algo.layout.Vector

magnitude() → {number}

magnitude of the vector
Source:
Returns:
Type
number

multiply(n) → {algo.layout.Vector}

multiple by n and return a new vector
Parameters:
Name Type Description
n
Source:
Returns:
Type
algo.layout.Vector

normal() → {algo.layout.Vector}

normal of the vector
Source:
Returns:
Type
algo.layout.Vector

normalise() → {*}

normalize the vector, returns a new vector
Source:
Returns:
Type
*

subtract(v2) → {algo.layout.Vector}

subtract v2 and return a new vector
Parameters:
Name Type Description
v2
Source:
Returns:
Type
algo.layout.Vector