{"name":"robust-predicates","version":"3.0.3","description":"Fast robust predicates for computational geometry","keywords":["computational geometry","robust arithmetic"],"author":{"name":"Vladimir Agafonkin"},"license":"Unlicense","type":"module","main":"index.js","unpkg":"umd/predicates.min.js","module":"index.js","exports":"./index.js","types":"index.d.ts","scripts":{"build":"mkdir -p esm && node compile.js","lint":"eslint *.js src test/test.js","pretest":"npm run lint && npm run build","test":"node --test","cov":"node --test --experimental-test-coverage","bench":"node bench.js","prepublishOnly":"npm run test && rollup -c"},"devDependencies":{"@rollup/plugin-terser":"^1.0.0","eslint":"^10.1.0","eslint-config-mourner":"^4.1.0","nextafter":"^1.0.0","robust-in-sphere":"^1.2.1","robust-orientation":"^1.2.1","rollup":"^4.59.1"},"repository":{"type":"git","url":"git+https://github.com/mourner/robust-predicates.git"},"gitHead":"8bed7fadb4284911e1111876e54a6f8acfa445cd","_id":"robust-predicates@3.0.3","bugs":{"url":"https://github.com/mourner/robust-predicates/issues"},"homepage":"https://github.com/mourner/robust-predicates#readme","_nodeVersion":"24.14.0","_npmVersion":"11.11.0","dist":{"integrity":"sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==","shasum":"1099061b3349e2c5abec6c2ab0acd440d24d4062","tarball":"http://registry-npm.ywwl.com/robust-predicates/download/robust-predicates-3.0.3.tgz","fileCount":20,"unpackedSize":293521,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDvA9x8rXmq8tLZOQYCmVkcZl4/y2HkhVLYc6/2TUF3ggIgKV41mW0vaP5nlTMzhiL5UrTraLmZwhhpg7l4QVLq0vI="}],"size":40820,"noattachment":false,"key":"/robust-predicates/-/robust-predicates-3.0.3.tgz"},"_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"directories":{},"maintainers":[{"name":"mourner","email":"agafonkin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/robust-predicates_3.0.3_1774175298971_0.30354530746164676"},"_hasShrinkwrap":false,"readme":"# robust-predicates\n\nFast robust predicates for computational geometry in JavaScript. Provides reliable 2D and 3D point orientation tests (`orient2d`, `orient3d`, `incircle`, `insphere`) that are not susceptible to floating point errors (without sacrificing performance). A modern port of [Jonathan R Shewchuk's C code](https://www.cs.cmu.edu/~quake/robust.html), an industry standard since 1996.\n\n<a href=\"https://observablehq.com/@mourner/non-robust-arithmetic-as-art\"><img width=\"600\" height=\"200\" src=\"predicates.png\" /></a>\n\n_Figure: non-robust vs robust `orient2d` test for points within a tiny range (2<sup>-42</sup>)._\n\n[![Build Status](https://github.com/mourner/robust-predicates/actions/workflows/node.yml/badge.svg)](https://github.com/mourner/robust-predicates/actions/workflows/node.yml)\n[![Simply Awesome](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)\n[![Browser Build](https://img.shields.io/bundlephobia/minzip/robust-predicates)](https://unpkg.com/robust-predicates)\n\n## [Demo](https://observablehq.com/@mourner/non-robust-arithmetic-as-art)\n\n## API\n\nNote: unlike J. Shewchuk's original code, all the functions in this library assume `y` axis is oriented _downwards_ &darr;, so the semantics are different.\n\n### `orient2d(ax,ay, bx,by, cx,cy)`\n\n- Returns a *positive* value if the points `a`, `b`, and `c` occur in _counterclockwise_ order (`c` lies to the left of the directed line defined by points `a` and `b`).\n- Returns a *negative* value if they occur in _clockwise_ order (`c` lies to the right of the directed line `ab`).\n- Returns *zero* if they are _collinear_.\n\nThe result is also an approximation of twice the signed area of the triangle defined by the three points.\n\n### `incircle(ax,ay, bx,by, cx,cy, dx,dy)`\n\n- Returns a _positive_ value if the point `d` lies _outside_ the circle passing through `a`, `b`, and `c`.\n- Returns a _negative_ value if it lies _inside_.\n- Returns _zero_ if the four points are _cocircular_.\n\nThe points `a`, `b`, and `c` must be in _counterclockwise_ order, or the sign of the result will be reversed.\n\n### `orient3d(ax,ay,az, bx,by,bz, cx,cy,cz, dx,dy,dz)`\n\n- Returns a _positive_ value if the point `d` lies _above_ the plane passing through `a`, `b`, and `c`, meaning that `a`, `b`, and `c` appear in counterclockwise order when viewed from `d`.\n- Returns a _negative_ value if `d` lies _below_ the plane.\n- Returns _zero_ if the points are _coplanar_.\n\nThe result is also an approximation of six times the signed volume of the tetrahedron defined by the four points.\n\n### `insphere(ax,ay,az, bx,by,bz, cx,cy,cz, dx,dy,dz, ex,ey,ez)`\n\n- Returns a _positive_ value if the point `e` lies _outside_ the sphere passing through `a`, `b`, `c`, and `d`.\n- Returns a _negative_ value if it lies _inside_.\n- Returns _zero_ if the five points are _cospherical_.\n\nThe points `a`, `b`, `c`, and `d` must be ordered so that they have a _positive orientation_\n(as defined by `orient3d`), or the sign of the result will be reversed.\n\n### `orient2dfast`, `orient3dfast`, `incirclefast`, `inspherefast`\n\nSimple, approximate, non-robust versions of predicates above. Use when robustness isn't needed.\n\n## Example\n\n```js\nimport {orient2d} from 'robust-predicates';\n\nconst ccw = orient2d(ax, ay, bx, by, cx, cy) > 0;\n````\n\n## Install\n\nInstall with `npm install robust-predicates` or `yarn add robust-predicates`, or use one of the browser builds:\n\n- [predicates.min.js](https://unpkg.com/robust-predicates/umd/predicates.min.js) (all predicates)\n- [orient2d.min.js](https://unpkg.com/robust-predicates/umd/orient2d.min.js) (`orient2d`, `orient2dfast`)\n- [orient3d.min.js](https://unpkg.com/robust-predicates/umd/orient3d.min.js) (`orient3d`, `orient3dfast`)\n- [incircle.min.js](https://unpkg.com/robust-predicates/umd/incircle.min.js) (`incircle`, `incirclefast`)\n- [insphere.min.js](https://unpkg.com/robust-predicates/umd/insphere.min.js) (`insphere`, `inspherefast`)\n\n## Thanks\n\nThis project is just a port — all the brilliant, hard work was done by [Jonathan Richard Shewchuk](https://people.eecs.berkeley.edu/~jrs/).\n\nThe port was also inspired by [Mikola Lysenko](https://twitter.com/MikolaLysenko)'s excellent [Robust Arithmetic Notes](https://github.com/mikolalysenko/robust-arithmetic-notes) and related projects like [robust-orientation](https://github.com/mikolalysenko/robust-orientation) and [robust-in-sphere](https://github.com/mikolalysenko/robust-in-sphere).\n\n## License\n\nSince the original code is in the public domain, this project follows the same choice. See [Unlicense](https://unlicense.org).\n","publish_time":1774175299122,"_cnpm_publish_time":1774175299122,"dist-tags":{"latest":"3.0.3"}}