{"id":17317275,"url":"https://github.com/mauriciopoppe/quickhull3d","last_synced_at":"2025-04-06T02:09:24.280Z","repository":{"id":27806166,"uuid":"31295512","full_name":"mauriciopoppe/quickhull3d","owner":"mauriciopoppe","description":"A JS library to find the convex hull of a finite set of 3d points","archived":false,"fork":false,"pushed_at":"2024-08-31T06:02:08.000Z","size":1320,"stargazers_count":143,"open_issues_count":2,"forks_count":17,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-30T00:09:04.313Z","etag":null,"topics":["3d","computer-graphics","convex-hull","javascript","quickhull","quickhull-3d","typescript"],"latest_commit_sha":null,"homepage":"http://mauriciopoppe.github.io/quickhull3d/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauriciopoppe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-25T03:34:49.000Z","updated_at":"2025-03-17T18:32:11.000Z","dependencies_parsed_at":"2024-06-18T18:11:39.774Z","dependency_job_id":"1b0ec8c7-e41e-4448-8cff-3b67490a6dfc","html_url":"https://github.com/mauriciopoppe/quickhull3d","commit_stats":{"total_commits":126,"total_committers":4,"mean_commits":31.5,"dds":0.2222222222222222,"last_synced_commit":"516a3f11acbe8f276fb55e6c88061188289b7009"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciopoppe%2Fquickhull3d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciopoppe%2Fquickhull3d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciopoppe%2Fquickhull3d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauriciopoppe%2Fquickhull3d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauriciopoppe","download_url":"https://codeload.github.com/mauriciopoppe/quickhull3d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423515,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","computer-graphics","convex-hull","javascript","quickhull","quickhull-3d","typescript"],"created_at":"2024-10-15T13:16:04.711Z","updated_at":"2025-04-06T02:09:24.249Z","avatar_url":"https://github.com/mauriciopoppe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# quickhull3d\n\n[![NPM version][npm-image]][npm-url]\n[![Codecov Status][codecov-image]][codecov-url]\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmauriciopoppe%2Fquickhull3d.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmauriciopoppe%2Fquickhull3d?ref=badge_shield)\n\nA robust quickhull implementation to find the convex hull of a set of 3d points in `O(n log n)` ported from [John Lloyd implementation](http://www.cs.ubc.ca/~lloyd/java/quickhull3d.html)\n\nAdditional implementation material:\n\n- Dirk Gregorius presentation: https://archive.org/details/GDC2014Gregorius\n- Convex Hull Generation with Quick Hull by Randy Gaul (lost link)\n\n[This library was incorporated into ThreeJS!](https://github.com/mrdoob/three.js/pull/10987). Thanks to https://github.com/Mugen87 for his work to move the primitives to ThreeJS primitives, the quickhull3d library will always be library agnostic and will operate with raw arrays.\n\n## Features\n\n- Key functions are well documented (including ascii graphics)\n- [Faster](https://plot.ly/~maurizzzio/36/quickhull3d-vs-convexhull/) than other JavaScript implementations of convex hull\n\n## Demo\n\nClick on the image to see a demo!\n\n[![demo](./docs/quickhull3d.png)](http://mauriciopoppe.github.io/quickhull3d/)\n\n## Minimal browser demo (using v3 or above)\n\n```html\n\u003cscript type=\"module\"\u003e\n  import qh from 'https://cdn.jsdelivr.net/npm/quickhull3d@\u003cversion\u003e/+esm'\n\n  const points = [\n    [0, 1, 0],\n    [1, -1, 1],\n    [-1, -1, 1],\n    [0, -1, -1]\n  ]\n\n  const faces = qh(points)\n  console.log(faces)\n  // output:\n  // [ [ 2, 1, 0 ], [ 3, 1, 2 ], [ 3, 0, 1 ], [ 3, 2, 0 ] ]\n  // 1st face:\n  //   points[2] = [-1, -1, 1]\n  //   points[1] = [1, -1, 1]\n  //   points[0] = [0, 1, 0]\n  //   normal = (points[1] - points[2]) x (points[0] - points[2])\n\u003c/script\u003e\n```\n\n## Installation\n\n```bash\n$ npm install --save quickhull3d\n```\n\n## Usage\n\n```javascript\nimport qh from 'quickhull3d'\n```\n\n### `qh(points, options)`\n\n**params**\n* `points` {Array\u003cArray\u003cnumber\u003e\u003e} an array of 3d points whose convex hull needs to be computed\n* `options` {Object} (optional)\n* `options.skipTriangulation` {Boolean} True to skip the triangulation of the faces\n    (returning n-vertex faces)\n\n**returns** An array of 3 element arrays, each subarray has the indices of 3 points which form a face whose normal points outside the polyhedra\n\n### `isPointInsideHull(point, points, faces)`\n\n**params**\n* `point` {Array\u003cnumber\u003e} The point that we want to check that it's a convex hull.\n* `points` {Array\u003cArray\u003cnumber\u003e\u003e} The array of 3d points whose convex hull was computed\n* `faces` {Array\u003cArray\u003cnumber\u003e\u003e} An array of 3 element arrays, each subarray has the indices of 3 points which form a face whose normal points outside the polyhedra\n\n**returns** `true` if the point `point` is inside the convex hull\n\n**example**\n\n```javascript\nimport qh, { isPointInsideHull } from 'quickhull3d'\n\nconst points = [\n  [0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1],\n  [1, 1, 0], [1, 0, 1], [0, 1, 1], [1, 1, 1]\n]\nconst faces = qh(points)\nexpect(isPointInsideHull([0.5, 0.5, 0.5], points, faces)).toBe(true)\nexpect(isPointInsideHull([0, 0, -0.1], points, faces)).toBe(false)\n```\n\n### Constructor\n\n```javascript\nimport QuickHull from 'quickhull3d/dist/QuickHull'\n```\n\n#### `instance = new QuickHull(points)`\n\n**params**\n* `points` {Array} an array of 3d points whose convex hull needs to be computed\n\n#### `instance.build()`\n\nComputes the quickhull of all the points stored in the instance\n\n**time complexity** `O(n log n)`\n\n#### `instance.collectFaces(skipTriangulation)`\n\n**params**\n* `skipTriangulation` {Boolean} (default: false) True to skip the triangulation\n    and return n-vertices faces\n\n**returns**\n\nAn array of 3-element arrays (or n-element arrays if `skipTriangulation = true`)\nwhich are the faces of the convex hull\n\n## Example\n\n```javascript\nimport qh from 'quickhull3d'\nconst points = [\n  [0, 1, 0],\n  [1, -1, 1],\n  [-1, -1, 1],\n  [0, -1, -1]\n]\n\nqh(points)\n// output:\n// [ [ 2, 0, 3 ], [ 0, 1, 3 ], [ 2, 1, 0 ], [ 2, 3, 1 ] ]\n// 1st face:\n//   points[2] = [-1, -1, 1]\n//   points[0] = [0, 1, 0]\n//   points[3] = [0, -1, -1]\n//   normal = (points[0] - points[2]) x (points[3] - points[2])\n```\n\nUsing the constructor:\n\n```javascript\nimport { QuickHull } from 'quickhull3d'\nconst points = [\n  [0, 1, 0],\n  [1, -1, 1],\n  [-1, -1, 1],\n  [0, -1, -1]\n];\nconst instance = new QuickHull(points)\ninstance.build()\ninstance.collectFaces()   // returns an array of 3-element arrays\n```\n\n## Benchmarks\n\nSpecs:\n\n```\nMacBook Pro (Retina, Mid 2012)\n2.3 GHz Intel Core i7\n8 GB 1600 MHz DDR3\nNVIDIA GeForce GT 650M 1024 MB\n```\n\nVersus [`convex-hull`](https://www.npmjs.com/package/convex-hull)\n\n```\n// LEGEND: program:numberOfPoints\nquickhull3d:100 x 6,212 ops/sec 1.24% (92 runs sampled)\nconvexhull:100 x 2,507 ops/sec 1.20% (89 runs sampled)\nquickhull3d:1000 x 1,171 ops/sec 0.93% (97 runs sampled)\nconvexhull:1000 x 361 ops/sec 1.38% (88 runs sampled)\nquickhull3d:10000 x 190 ops/sec 1.33% (87 runs sampled)\nconvexhull:10000 x 32.04 ops/sec 2.37% (56 runs sampled)\nquickhull3d:100000 x 11.90 ops/sec 6.34% (34 runs sampled)\nconvexhull:100000 x 2.81 ops/sec 2.17% (11 runs sampled)\nquickhull3d:200000 x 5.11 ops/sec 10.05% (18 runs sampled)\nconvexhull:200000 x 1.23 ops/sec 3.33% (8 runs sampled)\n```\n\n[![quickhull3d vs convexhull](https://cloud.githubusercontent.com/assets/1616682/11645526/97036bea-9d2b-11e5-8549-8ccba137f1b2.png)](https://plot.ly/~maurizzzio/36/quickhull3d-vs-convexhull/)\n\n## License\n\nMauricio Poppe. Licensed under the MIT license.\n\n[npm-url]: https://npmjs.org/package/quickhull3d\n[npm-image]: https://img.shields.io/npm/v/quickhull3d.svg?style=flat\n\n[codecov-url]: https://codecov.io/github/mauriciopoppe/quickhull3d\n[codecov-image]: https://img.shields.io/codecov/c/github/mauriciopoppe/quickhull3d.svg?style=flat\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmauriciopoppe%2Fquickhull3d.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmauriciopoppe%2Fquickhull3d?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciopoppe%2Fquickhull3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauriciopoppe%2Fquickhull3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauriciopoppe%2Fquickhull3d/lists"}