{"_id":"justmath","_rev":"31-2d7cb0ba668de480d8440c16c209eda4","name":"justmath","description":"JustMath.js: Two dimensional vector math including a rich toolset for vector operations.","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"justmath","version":"1.0.0","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"description":"An implementation of two dimensional vector math including a rich toolset for vector operations.","contributors":[{"name":"Daniel Wirtz","email":"dcode@dcode.io"}],"main":"JustMath.js","repository":{"type":"git","url":"https://github.com/dcodeIO/JustMath.js.git"},"keywords":["vector","math","2d"],"dependencies":{},"devDependencies":{"uglify-js":">=2"},"license":"Apache License, Version 2.0","engines":{"node":">=0.6"},"scripts":{"prepublish":"npm test","minify":"uglifyjs JustMath.js -o JustMath.min.js --comments","jsdoc":"jsdoc -c jsdoc.json","pretest":"npm run-script minify"},"readme":"JustMath.js - 2D Vector Math [![Build Status](https://travis-ci.org/dcodeIO/JustMath.js.png?branch=master)](https://travis-ci.org/dcodeIO/JustMath.js)\r\n============================\r\nAn implementation of two dimensional vector math including a rich toolset for vector operations. It's also the math\r\nlibrary behind [eSoccer](http://www.esoccer.me), a cross-platform multiplayer HTML5 game developed at [University of\r\nApplied Sciences Bonn](http://www.h-brs.de).\r\n\r\nJustMath\r\n--------\r\n* Augments core Math\r\n* Allows replacement of all methods (e.g. custom implementations of `JustMath.sqrt(value)`)\r\n* Adds some convenience methods (`JustMath.sq(value)`, `JustMath.cot(angle)`)\r\n\r\nJustMath.Vec2\r\n-------------\r\n* Vector instantiation (`new Vec2(vOrX[, y])`) and cloning (`Vec2#clone()`)\r\n* Direct modification through `Vec2#x` and `Vec2#y`, also provides getters (`Vec2#getX()`, `Vec2#getY()`) and a setter\r\n (`Vec2#set(vOrX[, y])`)\r\n* Vector addition (`Vec2#add(vOrX[, y])`), subtraction (`Vec2#sub(vOrX[, y])`) and multiplication\r\n  (`Vec2#dot(vOrX[, y]))`)\r\n* Vector orthogonality (`Vec2#ort()`)\r\n* Vector normalization (`Vec2#norm()`), scaling (`Vec2#scale(factor)`), inversion (`Vec2#inv()`) and magnitude\r\n  (`Vec2#mag()`, `Vec2#magSq()`) calculation\r\n* Vector-Vector distances (`Vec2#dist(b)`, `Vec2#distSq(b)`)\r\n* Vector rotation (`Vec2#rot(angle)`) and direction calculation (`Vec2#dir()`)\r\n* Vector projection (`Vec2#project(b)`) and rejection (`Vec2#reject(b)`)\r\n* Vector reflection (`Vec2#reflect(n)`), also with component-wise (projected and rejected component) scaling \r\n  (`Vec2#reflectAndScale(n, projectFactor, rejectFactor)`)\r\n* Vector interpolation (`Vec2#lerp(p, percent)`)\r\n* Vector containment in rectangle (`Vec2#inRect(p1, p2)`)\r\n* [Vector,Vector] determinant calculation (`Vec2.det(v1, v2)`)\r\n* Provides Vector#toString and `Vector#equals()`\r\n* Provides vector operation chaining, e.g.\r\n  \r\n  ```javascript\r\n  var a = new Vec2(1,2);\r\n  var b = new Vec2(2,1);\r\n  var n = new Vec2(0,1);\r\n  a.clone().sub(b).norm().project(n)...\r\n  ```\r\n  \r\n* Provides `Vec2#toString()` for pain-free debugging\r\n* Is of course able to evaluate `Vec2#equals(b)`\r\n* Exports and imports JSON payloads (`Vec2#getXY()`, `new Vec2(jsonPayload)`)\r\n* Small allocation footprint when using `Vec2#clone()` wisely\r\n* Accepts another Vec2 or plain X and Y coordinates as parameters where possible (e.g. `Vec2#add(vOrX[, y])`)\r\n\r\nFeatures\r\n--------\r\n* [CommonJS](http://www.commonjs.org/) compatible\r\n* [RequireJS](http://requirejs.org/)/AMD compatible\r\n* Shim compatible\r\n* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/justmath) (npm install justmath)\r\n* [Closure Compiler](https://developers.google.com/closure/compiler/) ADVANCED_OPTIMIZATIONS compatible (fully annotated)\r\n* Fully documented ([jsdoc3](https://github.com/jsdoc3/jsdoc))\r\n* Zero dependencies and prerequisites\r\n* Small footprint\r\n\r\nUsage\r\n-----\r\n### Node.js / CommonJS ###\r\n* Install: `npm install justmath`\r\n\r\n```javascript\r\nvar JustMath = require(\"justmath\"),\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nconsole.log(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\n### Browser (shim) ###\r\n\r\n```html\r\n<script src=\"//raw.github.com/dcodeIO/JustMath.js/master/JustMath.min.js\"></script>\r\n```\r\n\r\n```javascript\r\nvar JustMath = dcodeIO.JustMath,\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nalert(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\n### RequireJS / AMD ###\r\n\r\n```javascript\r\nvar JustMath = require(\"/path/to/JustMath.js\"),\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nalert(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\nDownloads\r\n---------\r\n* [ZIP-Archive](https://github.com/dcodeIO/JustMath.js/archive/master.zip)\r\n* [Tarball](https://github.com/dcodeIO/JustMath.js/tarball/master)\r\n\r\nDocumentation\r\n-------------\r\n* [View documentation](http://htmlpreview.github.com/?http://github.com/dcodeIO/JustMath.js/master/docs/JustMath.html)\r\n\r\nExamples & Tests\r\n----------------\r\n* [Run tests](http://htmlpreview.github.com/?https://github.com/dcodeIO/JustMath.js/master/examples/Vec2.html) (requires working HTML5 Canvas)\r\n* [View source](https://github.com/dcodeIO/JustMath.js/blob/master/examples/Vec2.html)\r\n\r\nLicense\r\n-------\r\nApache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html","readmeFilename":"README.md","_id":"justmath@1.0.0","dist":{"shasum":"c70a1488eb934c3051bf5418c1e7165303036639","tarball":"https://registry.npmjs.org/justmath/-/justmath-1.0.0.tgz","integrity":"sha512-6ZaNuSaSYGgTTn6/O/8/GwmM53Tyxb57NQjYb276Kny7I5stpeEb/EMbQP7Hr/Z/NRBnBqk7XKPpVM6yyU/k4Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGNMAJd3G+niqox4+phYfm0EL73cdw7sKjbpqmrEj1QzAiEAtHelrOAigELXwbrNko6ZBe561DP3OzmpaY8miS+PfOU="}]},"_npmVersion":"1.2.0","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":"dcode@dcode.io"}],"directories":{}},"1.0.1":{"name":"justmath","version":"1.0.1","author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"description":"JustMath.js: Two dimensional vector math including a rich toolset for vector operations.","main":"JustMath.js","repository":{"type":"git","url":"https://github.com/dcodeIO/JustMath.js.git"},"bugs":{"url":"https://github.com/dcodeIO/JustMath.js/issues"},"keywords":["vector","math","2d"],"dependencies":{},"devDependencies":{"nodeunit":">=0.7","closurecompiler":">=1.1"},"license":"Apache License, Version 2.0","engines":{"node":">=0.8"},"scripts":{"prepublish":"npm test","test":"nodeunit tests/suite.js","make":"npm run-script compile && npm run-script noexpose && npm test && npm run-script jsdoc","compile":"ccjs JustMath.js --create_source_map=JustMath.min.map --compilation_level=ADVANCED_OPTIMIZATIONS > JustMath.min.js","noexpose":"cat JustMath.js | grep -v @expose > JustMath.noexpose.js","jsdoc":"jsdoc -c jsdoc.json"},"readme":"![JustMath.js - 2D Vector Math](https://raw.github.com/dcodeIO/JustMath.js/master/JustMath.png)\r\n============================\r\nAn implementation of two dimensional vector math including a rich toolset for vector operations. It's also the math\r\nlibrary behind [eSoccer](http://www.esoccer.me), a cross-platform multiplayer HTML5 game developed at [University of\r\nApplied Sciences Bonn](http://www.h-brs.de).\r\n\r\nJustMath\r\n--------\r\n* Augments core Math\r\n* Allows replacement of all methods (e.g. custom implementations of `JustMath.sqrt(value)`)\r\n* Adds some convenience methods (`JustMath.sq(value)`, `JustMath.cot(angle)`)\r\n\r\nJustMath.Vec2\r\n-------------\r\n* Vector instantiation (`new Vec2(vOrX[, y])`) and cloning (`Vec2#clone()`)\r\n* Direct modification through `Vec2#x` and `Vec2#y`, also provides getters (`Vec2#getX()`, `Vec2#getY()`) and a setter\r\n (`Vec2#set(vOrX[, y])`)\r\n* Vector addition (`Vec2#add(vOrX[, y])`), subtraction (`Vec2#sub(vOrX[, y])`) and multiplication\r\n  (`Vec2#dot(vOrX[, y]))`)\r\n* Vector orthogonality (`Vec2#ort()`)\r\n* Vector normalization (`Vec2#norm()`), scaling (`Vec2#scale(factor)`), inversion (`Vec2#inv()`) and magnitude\r\n  (`Vec2#mag()`, `Vec2#magSq()`) calculation\r\n* Vector-Vector distances (`Vec2#dist(b)`, `Vec2#distSq(b)`)\r\n* Vector rotation (`Vec2#rot(angle)`) and direction calculation (`Vec2#dir()`)\r\n* Vector projection (`Vec2#project(b)`) and rejection (`Vec2#reject(b)`)\r\n* Vector reflection (`Vec2#reflect(n)`), also with component-wise (projected and rejected component) scaling \r\n  (`Vec2#reflectAndScale(n, projectFactor, rejectFactor)`)\r\n* Vector interpolation (`Vec2#lerp(p, percent)`)\r\n* Vector containment in rectangle (`Vec2#inRect(p1, p2)`)\r\n* [Vector,Vector] determinant calculation (`Vec2.det(v1, v2)`)\r\n* Provides Vector#toString and `Vector#equals()`\r\n* Provides vector operation chaining, e.g.\r\n  \r\n  ```javascript\r\n  var a = new Vec2(1,2);\r\n  var b = new Vec2(2,1);\r\n  var n = new Vec2(0,1);\r\n  a.clone().sub(b).norm().project(n)...\r\n  ```\r\n  \r\n* Provides `Vec2#toString()` for pain-free debugging\r\n* Is of course able to evaluate `Vec2#equals(b)`\r\n* Exports and imports JSON payloads (`Vec2#getXY()`, `new Vec2(jsonPayload)`)\r\n* Small allocation footprint when using `Vec2#clone()` wisely\r\n* Accepts another Vec2 or plain X and Y coordinates as parameters where possible (e.g. `Vec2#add(vOrX[, y])`)\r\n\r\nFeatures\r\n--------\r\n* [CommonJS](http://www.commonjs.org/) compatible\r\n* [RequireJS](http://requirejs.org/)/AMD compatible\r\n* Shim compatible\r\n* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/justmath) (npm install justmath)\r\n* [Closure Compiler](https://developers.google.com/closure/compiler/) ADVANCED_OPTIMIZATIONS compatible (fully annotated)\r\n* Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)\r\n* Zero dependencies and prerequisites\r\n* Small footprint\r\n\r\nUsage\r\n-----\r\n### Node.js / CommonJS ###\r\n* Install: `npm install justmath`\r\n\r\n```javascript\r\nvar JustMath = require(\"justmath\"),\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nconsole.log(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\n### Browser (shim) ###\r\n\r\n```html\r\n<script src=\"//raw.github.com/dcodeIO/JustMath.js/master/JustMath.min.js\"></script>\r\n```\r\n\r\n```javascript\r\nvar JustMath = dcodeIO.JustMath,\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nalert(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\n### RequireJS / AMD ###\r\n\r\n```javascript\r\nvar JustMath = require(\"/path/to/JustMath.js\"),\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nalert(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\nDownloads\r\n---------\r\n* [ZIP-Archive](https://github.com/dcodeIO/JustMath.js/archive/master.zip)\r\n* [Tarball](https://github.com/dcodeIO/JustMath.js/tarball/master)\r\n\r\nDocumentation\r\n-------------\r\n* [View documentation](http://htmlpreview.github.com/?http://github.com/dcodeIO/JustMath.js/master/docs/JustMath.html)\r\n\r\nExamples & Tests [![Build Status](https://travis-ci.org/dcodeIO/JustMath.js.png?branch=master)](https://travis-ci.org/dcodeIO/JustMath.js)\r\n----------------\r\n* [Run visual tests](http://htmlpreview.github.com/?https://github.com/dcodeIO/JustMath.js/master/examples/Vec2.html) (requires working HTML5 Canvas)\r\n* [View source](https://github.com/dcodeIO/JustMath.js/blob/master/examples/Vec2.html)\r\n* [View deploy tests source](https://github.com/dcodeIO/JustMath.js/blob/master/tests/suite.js)\r\n\r\nLicense\r\n-------\r\nApache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html","readmeFilename":"README.md","_id":"justmath@1.0.1","dist":{"shasum":"8d5a71b1691b149c209108266df8a981025428aa","tarball":"https://registry.npmjs.org/justmath/-/justmath-1.0.1.tgz","integrity":"sha512-TupIOuwTTvmcg8aRdmrh6ODyz1IcXYMN10yp1fDTK60nEY3ZAtml2sQCaEgwtt/3TqqvKMafyVzLeE7T14/HYQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFf8sXA62YK5+vwP4x7EvTIc6/jTgGtM6TyYeHTVpy66AiEApUBtCBMqkc0BWBL2IBW8v6WGn0YmRau5boEnpVS0sDM="}]},"_npmVersion":"1.2.0","_npmUser":{"name":"dcode","email":"dcode@dcode.io"},"maintainers":[{"name":"dcode","email":"dcode@dcode.io"}]}},"readme":"JustMath.js - 2D Vector Math [![Build Status](https://travis-ci.org/dcodeIO/JustMath.js.png?branch=master)](https://travis-ci.org/dcodeIO/JustMath.js)\r\n============================\r\nAn implementation of two dimensional vector math including a rich toolset for vector operations. It's also the math\r\nlibrary behind [eSoccer](http://www.esoccer.me), a cross-platform multiplayer HTML5 game developed at [University of\r\nApplied Sciences Bonn](http://www.h-brs.de).\r\n\r\nJustMath\r\n--------\r\n* Augments core Math\r\n* Allows replacement of all methods (e.g. custom implementations of `JustMath.sqrt(value)`)\r\n* Adds some convenience methods (`JustMath.sq(value)`, `JustMath.cot(angle)`)\r\n\r\nJustMath.Vec2\r\n-------------\r\n* Vector instantiation (`new Vec2(vOrX[, y])`) and cloning (`Vec2#clone()`)\r\n* Direct modification through `Vec2#x` and `Vec2#y`, also provides getters (`Vec2#getX()`, `Vec2#getY()`) and a setter\r\n (`Vec2#set(vOrX[, y])`)\r\n* Vector addition (`Vec2#add(vOrX[, y])`), subtraction (`Vec2#sub(vOrX[, y])`) and multiplication\r\n  (`Vec2#dot(vOrX[, y]))`)\r\n* Vector orthogonality (`Vec2#ort()`)\r\n* Vector normalization (`Vec2#norm()`), scaling (`Vec2#scale(factor)`), inversion (`Vec2#inv()`) and magnitude\r\n  (`Vec2#mag()`, `Vec2#magSq()`) calculation\r\n* Vector-Vector distances (`Vec2#dist(b)`, `Vec2#distSq(b)`)\r\n* Vector rotation (`Vec2#rot(angle)`) and direction calculation (`Vec2#dir()`)\r\n* Vector projection (`Vec2#project(b)`) and rejection (`Vec2#reject(b)`)\r\n* Vector reflection (`Vec2#reflect(n)`), also with component-wise (projected and rejected component) scaling \r\n  (`Vec2#reflectAndScale(n, projectFactor, rejectFactor)`)\r\n* Vector interpolation (`Vec2#lerp(p, percent)`)\r\n* Vector containment in rectangle (`Vec2#inRect(p1, p2)`)\r\n* [Vector,Vector] determinant calculation (`Vec2.det(v1, v2)`)\r\n* Provides Vector#toString and `Vector#equals()`\r\n* Provides vector operation chaining, e.g.\r\n  \r\n  ```javascript\r\n  var a = new Vec2(1,2);\r\n  var b = new Vec2(2,1);\r\n  var n = new Vec2(0,1);\r\n  a.clone().sub(b).norm().project(n)...\r\n  ```\r\n  \r\n* Provides `Vec2#toString()` for pain-free debugging\r\n* Is of course able to evaluate `Vec2#equals(b)`\r\n* Exports and imports JSON payloads (`Vec2#getXY()`, `new Vec2(jsonPayload)`)\r\n* Small allocation footprint when using `Vec2#clone()` wisely\r\n* Accepts another Vec2 or plain X and Y coordinates as parameters where possible (e.g. `Vec2#add(vOrX[, y])`)\r\n\r\nFeatures\r\n--------\r\n* [CommonJS](http://www.commonjs.org/) compatible\r\n* [RequireJS](http://requirejs.org/)/AMD compatible\r\n* Shim compatible\r\n* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/justmath) (npm install justmath)\r\n* [Closure Compiler](https://developers.google.com/closure/compiler/) ADVANCED_OPTIMIZATIONS compatible (fully annotated)\r\n* Fully documented ([jsdoc3](https://github.com/jsdoc3/jsdoc))\r\n* Zero dependencies and prerequisites\r\n* Small footprint\r\n\r\nUsage\r\n-----\r\n### Node.js / CommonJS ###\r\n* Install: `npm install justmath`\r\n\r\n```javascript\r\nvar JustMath = require(\"justmath\"),\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nconsole.log(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\n### Browser (shim) ###\r\n\r\n```html\r\n<script src=\"//raw.github.com/dcodeIO/JustMath.js/master/JustMath.min.js\"></script>\r\n```\r\n\r\n```javascript\r\nvar JustMath = dcodeIO.JustMath,\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nalert(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\n### RequireJS / AMD ###\r\n\r\n```javascript\r\nvar JustMath = require(\"/path/to/JustMath.js\"),\r\n    Vec2 = JustMath.Vec2;\r\nvar a = new Vec2(1,2);\r\nalert(\"Not more than \"+a.x+\", \"+a.y+\", 3.\");\r\n```\r\n\r\nDownloads\r\n---------\r\n* [ZIP-Archive](https://github.com/dcodeIO/JustMath.js/archive/master.zip)\r\n* [Tarball](https://github.com/dcodeIO/JustMath.js/tarball/master)\r\n\r\nDocumentation\r\n-------------\r\n* [View documentation](http://htmlpreview.github.com/?http://github.com/dcodeIO/JustMath.js/master/docs/JustMath.html)\r\n\r\nExamples & Tests\r\n----------------\r\n* [Run tests](http://htmlpreview.github.com/?https://github.com/dcodeIO/JustMath.js/master/examples/Vec2.html) (requires working HTML5 Canvas)\r\n* [View source](https://github.com/dcodeIO/JustMath.js/blob/master/examples/Vec2.html)\r\n\r\nLicense\r\n-------\r\nApache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html","maintainers":[{"name":"dcode","email":"dcode@dcode.io"}],"time":{"modified":"2022-06-19T07:28:49.191Z","created":"2013-02-28T01:09:18.210Z","1.0.0":"2013-02-28T01:09:20.404Z","1.0.1":"2013-03-12T13:20:32.968Z"},"author":{"name":"Daniel Wirtz","email":"dcode@dcode.io"},"repository":{"type":"git","url":"https://github.com/dcodeIO/JustMath.js.git"}}