UNPKG

vectors

Version:

A grab bag of vector utility functions for 2D and 3D vectors that operate on plain arrays

35 lines (23 loc) 567 B
/** ### `add(vec, other[, ...])` Adds the `other` vector to `vec`: ``` javascript var add = require('vectors/add')(2) var pos = [0, 0] var spd = [1, 1.5] add(pos, spd) add(pos, spd) console.log(pos) // [2, 3] ``` Or add a scalar to the entire array: ``` javascript var res = add([1, 1, 1], 6) console.log(res) // [7, 7, 7] ``` You can disable this by passing `scalars: false` to the generator function for faster results: ``` javascript var add = require('vectors/add')(2, { scalars: false }) ``` **/ module.exports = require('./lib/operator')('add', '+')