Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    polygon-centroidpublic

    polygon-centroid

    Return the centroid for a given convex polygon.

    Installation

    npm i polygon-centroid --save

    Usage

    centroid(points) Return the point {x, y} which is the centroid of the given set of points (convex polygon).

    Example

    var centroid = require('polygon-centroid');
    var center = centroid(this.polygon.points);
    this.polygon.anchor.set(center.x, center.y);
    this.polygon.rotation = Math.PI * 0.5;

    install

    npm i polygon-centroid

    Downloadsweekly downloads

    181

    version

    1.1.0

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar