robust-in-sphere is a JavaScript library providing an exact arithmetic test to determine if a collection of `n+2` points in `n`-dimensional space are cospherical, or if the last point is contained within the sphere defined by the preceding `n+1` points. This library focuses on robust predicates to avoid floating-point errors, a common issue in computational geometry, drawing inspiration from Jonathan Shewchuk's seminal work. Currently at version 1.2.1, it was last published in 2014, suggesting a stable but not actively developed state. Its primary differentiator is the use of exact arithmetic for geometric predicates, ensuring reliability over speed for critical calculations. While not as fast as some alternatives, its exactness is crucial for applications requiring high precision in geometric computations.
npm install robust-in-sphereVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `robust-in-sphere` to test point-in-sphere and cosphericity conditions for 2D and 3D points, illustrating the expected return values.
Ensure the number of points passed to `inSphere` strictly adheres to the `n+2` rule for `n`-dimensional inputs.
Use `const inSphere = require('robust-in-sphere')` for all imports. If using with modern ES Modules, consider using a compatibility layer or a bundler that handles CJS modules, or rewrite the import to `import inSphere = require('robust-in-sphere')` in TypeScript.Evaluate migration to a more actively maintained library like `robust-predicates`, which is a modern port inspired by Mikola Lysenko's work and Shewchuk's robust predicates.
Change the file to CommonJS (`.js` without `"type": "module"`) or use a bundler that transpiles CommonJS modules into ES modules. Alternatively, migrate to an ES module-compatible library if available.
Use the correct CommonJS import syntax: `const inSphere = require('robust-in-sphere')`.Always provide `n+2` points for an `n`-dimensional test. If you are testing cosphericity of 3D points, ensure 5 points are provided. If testing a point against a circle defined by two points in 2D, provide 4 points (the two defining points + the test point + an extra one to make it n+2 for n=2).