https://github.com/quentinroy/polygon-centroid
Calculate the centroid of any non-self-intersecting closed polygon.
https://github.com/quentinroy/polygon-centroid
centroid polygon
Last synced: about 1 year ago
JSON representation
Calculate the centroid of any non-self-intersecting closed polygon.
- Host: GitHub
- URL: https://github.com/quentinroy/polygon-centroid
- Owner: QuentinRoy
- License: other
- Created: 2018-01-29T11:08:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-03T16:48:52.000Z (over 1 year ago)
- Last Synced: 2025-04-18T03:32:24.638Z (about 1 year ago)
- Topics: centroid, polygon
- Language: JavaScript
- Homepage:
- Size: 195 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/QuentinRoy/polygon-centroid)
[](https://codecov.io/gh/QuentinRoy/polygon-centroid)
[](https://david-dm.org/quentinroy/polygon-centroid)
[](https://david-dm.org/quentinroy/polygon-centroid?type=dev)
[](https://www.npmjs.com/package/@quentinroy/polygon-centroid)
# @quentinroy/polygon-centroid
Calculate the centroid of any non-self-intersecting closed polygon.
## Install
`npm install @quentinroy/polygon-centroid`
## Example
```js
const polygonCentroid = require("@quentinroy/polygon-centroid");
const centroid = polygonCentroid([
{ x: 0, y: 0 },
{ x: 0, y: 1 },
{ x: 1, y: 1 },
]);
```