Vec23
A simple 2D and 3D Vector Library for JavaScript.
Version
0.1.0
Why another Vector Library?
I started to develop this library as part of a larger project because nothing seemed to satisfy my needs well. I wanted something with a plethora of intuitive methods for vector manipulation, as well as one which nicely supported functionality between 2D and 3D vectors, while still keeping them firmly separate.
I also wanted to create a more unopinionated vector library as far as whether methods should modify vectors in place or create new ones, since I found that most of the time I wanted a mix of both.
Vec23 is designed to provide 2D and 3D vectors. For a complete set of advanced mathematical constructs such as matrices and quaternions, look elsewhere.
Installation
Install via npm
$ npm install vec23 --save
or Bower
$ bower install vec23 --save
or download the vec23.js
file directly.
Dependencies
None!
Usage
If using CommonJS modules (such as node.js):
var Vec2 = Vec2;var Vec3 = Vec3;
If using AMD:
var Vec23 = ;var Vec2 = Vec23Vec2;var Vec3 = Vec23Vec3;
If loading in a browser:
Then create some vectors
var myVec2 = 10;var myVec3 = 100;
API
Each vector operation that produces another vector of the same type has two alternative class methods.
The method preceded with an underscore _
modifies and returns this
vector in place.
For example:
var vA = 123;var vB = vA;var vC = vA;console; //falseconsole; //true
For a complete API, see the documentation.
License
MIT