AMD Geometry and Matrix modules using reuse pattern for better performance
Using Bower:
$ bower install geomath --save
Using NuGet:
$ Install-Package GeoMath
Using NPM:
$ npm install geomath --save
You could use geomath in different context.
Include built script in your HTML file.
<script type="text/javascript" src="path/to/geomath.min.js"></script>
requirejs.config({
paths: {
math: 'path/to/geomath/math'
}
});
Then include promise in your dependencies.
define(["math"], function (math) {
math.geometry // Geometry Functions
math.matrix
math.matrix.M3 // Matrix 3x3 Functions
math.matrix.M4 // Matrix 4x4 Functions
math.matrix.V2 // Vector 2 Functions
math.matrix.V3 // Vector 3 Functions
});
define(["math/geometry", "math/matrix3"], function(geometry, M3) {
var area = geometry.area([0, 0], [0, 2], [2, 2], [2, 0]);
var matrix = M3.clone(M3.I);
M3.rotate(Math.PI / 2, matrix, matrix); // reuse
M3.scale([2, 2], matrix, matrix); // reuse
var translateMatrix = M3.translate([1, 1], matrix); // do not reuse
// ...
});
var math = require("geomath");
// Or
var matrix3 = require("geomath/math/matrix3");
For now documentation can be found in code.