This library, `robust-segment-intersect`, provides an exact arithmetic predicate to rigorously determine if two closed 2D line segments intersect. It is designed to overcome floating-point inaccuracies common in geometric computations, ensuring reliable results even in degenerate cases where endpoints are collinear or nearly so. The current stable version is 1.0.1, last published in 2014. As an older package, it is considered abandoned, meaning active development and new features are unlikely, though it remains functional for its specific purpose. Its primary differentiator lies in its 'exact arithmetic' approach, which prioritizes correctness over raw speed for applications requiring absolute precision in geometric intersection tests, such as CAD, GIS, and advanced rendering algorithms. Users should be aware of its CommonJS module format and consider its age when integrating into modern projects.
npm install robust-segment-intersectVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the `robust-segment-intersect` function and use it to check for intersection between two 2D line segments defined by their endpoints.
Consider mirroring the repository or migrating to a more actively maintained geometric library if long-term support or new features are required. For its specific functionality, it remains stable.
For ESM, use a default import: `import crosses from 'robust-segment-intersect'`. If `require` is unavailable, ensure your build setup (e.g., Webpack, Rollup) correctly handles CommonJS module interoperability.
Always pass points as `[x, y]` arrays. Validate input points before calling the function to ensure they conform to the expected `length 2` array structure.
Benchmarking is recommended if performance is a critical factor. For non-critical applications, the precision benefits typically outweigh the minor performance overhead.
Use a default import instead: `import crosses from 'robust-segment-intersect';` or stick to CommonJS `const crosses = require('robust-segment-intersect');`.Ensure all four arguments passed to `robust-segment-intersect` are valid 2-element arrays, like `[x, y]`, representing the coordinates of the segment endpoints.
For browser usage, bundle your code with a tool like Webpack or Rollup that handles CommonJS modules. For Node.js ESM projects, use `import crosses from 'robust-segment-intersect';` instead of `require`.
No dependency data recorded yet.