Vector

Vector

new Vector(mapping)

Source:

A Vector object with optional fields (ex: x,y,z,e)

Parameters:
Name Type Description
mapping any

object with fields to deep copy into this Vector

Methods

(static) add(v0, v1) → {object}

Source:

Add a vector object (x,y,z,e or whatever) to another and return a new Vector. TODO: Consider using toxiclibs or other Vector lib

Parameters:
Name Type Description
v0 Vector

first vector

v1 Vector

amount to add

Returns:

reference to this for chaining

Type
object

(static) div(v0, amt) → {Vector}

Source:

Divide a vector object (x,y,z,e or whatever) by an amount and return a new one.

Parameters:
Name Type Description
v0 Vector

first vector

amt number

amount to divide by

Returns:

new Vector

Type
Vector

(static) mult(v0, amt) → {Vector}

Source:

Multiply a vector object (x,y,z,e or whatever) by an amount and return a new one.

Parameters:
Name Type Description
v0 Vector

first vector

amt number

amount to divide by

Returns:

new Vector

Type
Vector

(static) sub(v0, v1) → {object}

Source:

Subtract a vector object (x,y,z,e or whatever) from another and return a new vector.

Parameters:
Name Type Description
v0 Vector

first vector

v1 Vector

amount to subtract

Returns:

reference to this for chaining

Type
object

addSelf(v0) → {object}

Source:

Add a vector object (x,y,z,e or whatever) to another and return itself.

Parameters:
Name Type Description
v0 Vector

amount to add

Returns:

reference to this for chaining

Type
object

dist(v0, v1) → {float}

Source:

Scalar distance between Vectors.

Parameters:
Name Type Description
v0 Vector

(required) first vector

v1 Vector

(optional) second vector (if not included, will use this)

Returns:

scalar vector

Type
float

divSelf(amt) → {Vector}

Source:

Divide a vector by a scalar

Parameters:
Name Type Description
amt Number

to divide by

Returns:

this object for chaining

Type
Vector

mag() → {float}

Source:

Magnitude of this vector as a scalar.

Returns:

magnitude

Type
float

magSq() → {float}

Source:

Magnitude squared of this vector as a scalar.

Returns:

magnitude

Type
float

multSelf(amt) → {Vector}

Source:

Multiply a vector by a scalar

Parameters:
Name Type Description
amt Number

to multiply by

Returns:

this object for chaining

Type
Vector

set(mapping) → {Vector}

Source:

Set the properties of this Vector based on another or a mapping object

Parameters:
Name Type Description
mapping object

object with fields to deep copy into this Vector

Returns:

this object for chaining

Type
Vector

subSelf(v0) → {object}

Source:

Subtract a vector object (x,y,z,e or whatever) from another and return a new vector. TODO: Consider using toxiclibs or other Vector lib

Parameters:
Name Type Description
v0 Vector

first vector

Returns:

reference to this for chaining

Type
object