vec3
3D vector math with robust unit tests.
Usage
var v = require('vec3');
var v1 = v(1, 2, 3);
console.log(v1);
var v2 = v1.offset(0, 0, 1);
console.log(v2);
Or:
var Vec3 = require('vec3').Vec3;
var v1 = new Vec3(1, 2, 3);
More available functions are listed below in Test Coverage.
Test Coverage
v()
β no args
β x, y, z
β array
β object
vec3
β floored
β floor
β offset
β translate
β plus
β minus
β scaled
β abs
β distanceTo
β equals
β toString
β clone
β add
β subtract
β set
β modulus
β volume
β min
β max
β update
β norm
β unit
β scale
β xyDistanceTo
β xzDistanceTo
β yzDistanceTo
β innerProduct
β manhattanDistanceTo
β toArray
36 tests complete
More functions welcome in the form of pull requests.
History
See History