An open API service indexing awesome lists of open source software.

https://github.com/ayamflow/polygon-centroid

Return the centroid for a given convex polygon.
https://github.com/ayamflow/polygon-centroid

Last synced: 11 months ago
JSON representation

Return the centroid for a given convex polygon.

Awesome Lists containing this project

README

          

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
```js
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;
```