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.
- Host: GitHub
- URL: https://github.com/ayamflow/polygon-centroid
- Owner: ayamflow
- Created: 2015-03-21T22:56:14.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T16:39:02.000Z (about 8 years ago)
- Last Synced: 2024-08-10T11:08:07.046Z (almost 2 years ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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;
```