sygonometry
v0.1.4
Published
A collection of geometric, trigonometric and other handy classes and functions. A common usecase for this library would be a game server that involves 2-dimensional movement and calculations.
Downloads
4
Maintainers
Readme
Node.js Sygonometry
A collection of geometric, trigonometric and other logical classes and functions. A common usecase for this library would be a game server that involves 2-dimensional movement and calculations. Crafted by [email protected]
Installation
npm install sygonometry --save
Usage
Require
var calc = require('sygonometry');
Examples: Movement
var pos = calc.Position(32, 64);
var vec = calc.Vector(calc.toRadians(90), 16);
console.log(pos);
pos.apply(vec);
console.log(pos);
var target = calc.Position(128, 256);
var dist = calc.getDistance(pos, target);
var angle = calc.getAngle(pos, target);
var area = calc.Area(32, 32, 256, 256);
if (target.within(area)) {
vec = calc.Vector(angle, dist);
pos.apply(vec);
console.log(pos);
console.log(target);
}
Release History
* 0.1.0 Initial Release
* 0.1.1 Fixed a few major bugs
* 0.1.2 Added some documentation
* 0.1.3 Removed a bug regarding clone() and fixed Example
* 0.1.4 Fixed Position.within()