centroid2d

2.0.0 • Public • Published

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! 🎉

Website 🌐

js@jacobsmith.tech

https://github.com/limeandcoconut

@limeandcoconut 🐦

Cheers!

License

ISC, see license for details.

Package Sidebar

Install

npm i centroid2d

Weekly Downloads

0

Version

2.0.0

License

ISC

Unpacked Size

3.94 kB

Total Files

6

Last publish

Collaborators

  • limeandcoconut