vec2d
Node.js 2d vector library with robust unit tests.
Usage
var v = ; var v1 = ;console; // prints "(1, 2)" var v2 = v1;console; // prints "(2, 2)" var v3 = ;console; // prints "(-1, 2.2)"
Or a faster, less convenient version:
var Vec2d = Vec2d; var v1 = 1 2;// etc...
More available functions are listed below in Test Coverage.
Test Coverage
v()
✓ no args
✓ x, y
✓ array
✓ object
✓ string coords
✓ deserialize
✓ invalid deserialize
✓ unit
Vec2d
✓ unit
✓ offset
✓ add
✓ sub
✓ plus
✓ minus
✓ neg
✓ mult
✓ times
✓ div
✓ divBy
✓ scale
✓ scaled
✓ clone
✓ apply
✓ applied
✓ equals
✓ toString
✓ length
✓ lengthSqrd
✓ angle
✓ normalize
✓ normalized
✓ boundMin
✓ boundMax
✓ floor
✓ floored
✓ ceil
✓ ceiled
- project
✓ dot
✓ rotate
✓ rotated
✓ distance
✓ distanceSqrd
✓ reflect
✓ reflectAboutLine
✓ set
45 passing (14ms)
1 pending
More functions welcome in the form of pull requests.