1.0.1 • Published 4 years ago

geomath v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

Geomath Build Status NPM version Bower version

AMD Geometry and Matrix modules using reuse pattern for better performance

Installation

Using Bower:

$ bower install geomath --save

Using NuGet:

$ Install-Package GeoMath

Using NPM:

$ npm install geomath --save

Usage

You could use geomath in different context.

Browser (with built file)

Include built script in your HTML file.

<script type="text/javascript" src="path/to/geomath.min.js"></script>

Browser (AMD from source)

Configure RequireJS.

requirejs.config({
    paths: {
        math: 'path/to/geomath/math'
    }
});

Then include promise in your dependencies.

Load all modules (not recommended)

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
});

Load modules independently

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
    // ...
});

Node (installed using NPM)

var math = require("geomath");
// Or
var matrix3 = require("geomath/math/matrix3");

Documentation

For now documentation can be found in code.