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 `convex-hull`

with all `npm`

packages installed. **Try it out**:

var convexHull = require("convex-hull")

- 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.

This module is a wrapper over various convex hull modules which exposes a simple interface for computing convex hulls of point sets in any dimension.

```
var ch = require('convex-hull')
var points = [
[0,0],
[1,0],
[0,1],
[0.15,0.15],
[0.5, 0.5]
]
//Picture:
//
// [0,1] *
// |\
// | \
// | \
// | \
// | \
// | \
// | \
// | * [0.5,0.5]
// | \
// | \
// | \
// | \
// | \
// | * \
// | [0.15,0.15] \
// [0,0] *---------------* [1,0]
//
console.log(ch(points))
```

Output:

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

```
npm install convex-hull
```

If you want to use it in a webpage, use browserify.

`require('convex-hull')(points)`

Computes the convex hull of `points`

`points`

is an array of points encoded as`d`

length arrays

**Returns** A polytope encoding the convex hull of the point set.

**Time complexity** The procedure takes O(n^floor(d/2) + n log(n)) time.

**Note** This module is a wrapper over incremental-convex-hull and monotone-convex-hull for convenience. It will select an optimal algorithm for whichever dimension is appropriate.

(c) 2014 Mikola Lysenko. MIT License

- package on npmhttps://npmjs.com/package/convex-hull
- homepagehttps://github.com/mikolalysenko/convex-hull
- 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