{"id":17918802,"url":"https://github.com/mourner/robust-predicates","last_synced_at":"2025-05-15T07:06:32.107Z","repository":{"id":57304228,"uuid":"205561091","full_name":"mourner/robust-predicates","owner":"mourner","description":"Fast robust predicates for computational geometry in JavaScript","archived":false,"fork":false,"pushed_at":"2024-07-03T07:51:22.000Z","size":491,"stargazers_count":307,"open_issues_count":1,"forks_count":17,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-11T18:24:57.407Z","etag":null,"topics":["computational-geometry","floating-point","predicates","robust-arithmetic"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mourner.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":"2019-08-31T15:20:36.000Z","updated_at":"2025-04-10T12:21:45.000Z","dependencies_parsed_at":"2024-01-15T16:22:33.557Z","dependency_job_id":"6ae71cef-33c4-4dcd-85ed-5eabd0783046","html_url":"https://github.com/mourner/robust-predicates","commit_stats":{"total_commits":84,"total_committers":1,"mean_commits":84.0,"dds":0.0,"last_synced_commit":"4bd3c7a28fa6dd906043c6e79416bf8cdd30a5a5"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Frobust-predicates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Frobust-predicates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Frobust-predicates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mourner%2Frobust-predicates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mourner","download_url":"https://codeload.github.com/mourner/robust-predicates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292042,"owners_count":22046426,"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":["computational-geometry","floating-point","predicates","robust-arithmetic"],"created_at":"2024-10-28T20:12:53.668Z","updated_at":"2025-05-15T07:06:27.078Z","avatar_url":"https://github.com/mourner.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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\u003ca href=\"https://observablehq.com/@mourner/non-robust-arithmetic-as-art\"\u003e\u003cimg width=\"600\" height=\"200\" src=\"predicates.png\" /\u003e\u003c/a\u003e\n\n_Figure: non-robust vs robust `orient2d` test for points within a tiny range (2\u003csup\u003e-42\u003c/sup\u003e)._\n\n[![Build Status](https://github.com/mourner/robust-predicates/workflows/Node/badge.svg?branch=main)](https://github.com/mourner/robust-predicates/actions)\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_ \u0026darr;, 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) \u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmourner%2Frobust-predicates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmourner%2Frobust-predicates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmourner%2Frobust-predicates/lists"}