This is a `playground`

to test code. It runs a full `Node.js`

environment and already has all of `npm`

’s 400,000 packages pre-installed, including `monotone-convex-hull-2d`

with all `npm`

packages installed. **Try it out**:

var monotoneConvexHull2d = require("monotone-convex-hull-2d")

- all documents on RunKit are public
`require()`

any package directly from npm- use arrow functions, classes, template strings, and most of ES6
`await`

any promise instead of using callbacks (example)- create your own embedded
**node.js**snippets

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

Computes the convex hull of a set of points in the plane in O(n log(n)) time using the Monotone chain algorithm.

```
var convexHull = require('monotone-convex-hull-2d')
var points = [
[0, 0],
[1, 0],
[0, 1],
[1, 1],
[0.5, 0.5]
]
console.log(convexHull(points))
```

Output:

```
[ 0, 2, 3, 1 ]
```

```
npm install monotone-convex-hull-2d
```

`require('monotone-convex-hull-2d')(points)`

Construct the convex hull of a set of points.

`points`

is an array of points represented as an array of length 2 arrays

**Returns** The convex hull of the point set represented by a clockwise oriented list of indices.

(c) 2014 Mikola Lysenko. MIT License

Visualizer (c) 2013 Dan Melanz

- package on npmhttps://npmjs.com/package/monotone-convex-hull-2d
- homepagehttps://github.com/mikolalysenko/monotone-convex-hull-2d
- licenseMIT

RunKit is a free, in-browser JavaScript dev environment for prototyping **Node.js** code, with every **npm** package installed. Sign up to share your code.

Sign Up for Free