centroid2d
v2.0.0
Published
A package to find the area weighted center of a convex polygon whose mass is evenly distributed across the surface.
Downloads
4
Maintainers
Readme
Centroid 2D
A package to find the area weighted center of a convex polygon whose mass is evenly distributed across the surface.
Usage
$ npm i centroid2d
const findCentroid = require('centroid2d)
let polygon = [
[0, 0],
[5, 0],
[5, 5],
[0, 5],
]
let centroid = findCentroid(polygon) // [2.5, 2.5]
Input must be an array of arrays of x and y coordinates.
There is no typechecking for simplicity and speed.
TODO:
Feedback ✉️
It is greatly appreciated! 🎉
https://github.com/limeandcoconut
Cheers!
License
ISC, see license for details.