A collection of terse vector utilities. A part of geom.
A vector is represented by an array with two elements.
-
Memory managed each utility has a pool of instances accessable using
_X_.make()and_X_.free(). If you don't need pooled instances, simply pass in your own object instead. -
State less no state is kept within the utilities, it's up to you.
var vec = require('geom-vec');
var a = vec.make(10,10);
vec.smul(a,10) // => [100,100]
vec.free(a)
See mocha generated API for the comprehensive API.
By default a console.warn() log is called whenever more vectors is allocated. Which is very useful to track any memory leaks. Set this property to false to silence it.
Copies vector a into vector b or returns a new vector.
Subtracts vector b from vector a into vector c or returns a new vector.
Adds vector b to vector a into vector c or returns a new vector.
Multiplies vector a with vector b into vector c or returns a new vector.
Divides vector a with vector b into vector c or returns a new vector.
Subtracts vector a with scalar s into vector c or returns a new vector.
Adds vector a with scalar s into vector c or returns a new vector.
Multiplies vector a with scalar s into vector c or returns a new vector.
Divides vector a with scalar s into vector c or returns a new vector.
MIT