{"id":20854366,"url":"https://github.com/w8r/segment-intersection","last_synced_at":"2025-07-13T19:08:30.459Z","repository":{"id":57748777,"uuid":"520663335","full_name":"w8r/segment-intersection","owner":"w8r","description":"Simple two segment intersection","archived":false,"fork":false,"pushed_at":"2024-02-18T21:39:43.000Z","size":362,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T03:52:26.625Z","etag":null,"topics":["geometry","segment-intersection"],"latest_commit_sha":null,"homepage":"https://w8r.github.io/segment-intersection","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/w8r.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":"2022-08-02T22:11:26.000Z","updated_at":"2023-02-24T11:05:03.000Z","dependencies_parsed_at":"2024-11-18T09:09:19.169Z","dependency_job_id":null,"html_url":"https://github.com/w8r/segment-intersection","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":0.09999999999999998,"last_synced_commit":"daf35ed1c0d82305064ed73a81893fbac85ed1a5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":"ms-fadaei/typescript-library-starter","purl":"pkg:github/w8r/segment-intersection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fsegment-intersection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fsegment-intersection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fsegment-intersection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fsegment-intersection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/w8r","download_url":"https://codeload.github.com/w8r/segment-intersection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fsegment-intersection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265191242,"owners_count":23725283,"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":["geometry","segment-intersection"],"created_at":"2024-11-18T03:25:30.571Z","updated_at":"2025-07-13T19:08:30.437Z","avatar_url":"https://github.com/w8r.png","language":"TypeScript","readme":"# `segment-intersection` ![checks](https://img.shields.io/github/checks-status/w8r/segment-intersection/main) ![npm](https://img.shields.io/npm/v/segment-intersection)\n\n![Screenshot](playground/screenshot.png)\n\nFast segment 2D intersection, that includes edge cases, such as segments touching points, or one segment being on top of the other.\n\n## API\n\n```ts\nimport { intersection, findIntersection } from 'segment-intersection';\n\nconst isect = findIntersection(x0, y0, x1, y1, x2, y2, x3, y3);\nconsole.log(isect); // 0, 1 or 2\nconsole.log(intersection); // [[x, y], [x, y]]\n```\n\n - `isect === 0` means the segments do not intersect. \n - `isect === 1` your intersection point is `intersection[0]`. \n - `isect === 2` your segments are overlapping and you have 2 intersection points, `intersection[0]` and `intersection[1]`. \n\nAlso, you can write into an existing array:\n\n```ts\nimport { findIntersection } from 'segment-intersection';\nconst intersection = [\n  [0, 0],\n  [0, 0],\n];\nconst isect = findIntersection(x0, y0, x1, y1, x2, y2, x3, y3, intersection);\n```\n\n### Benchmark\n\n```\n-  segment-intersection x 12,139,495 ops/sec ±0.81% (88 runs sampled)\n -  exact-segment-intersect x 1,149,191 ops/sec ±2.38% (89 runs sampled)\n -  segseg x 5,492,533 ops/sec ±4.01% (86 runs sampled)\n```\n\n### Run Playground\n\n```bash\nnpm run dev\n```\n\n### Build Playground (preview)\n\n```bash\nnpm run demo\n```\n\n### Build Library\n\n```bash\nnpm run build\n```\n\n### Lint\n\n```bash\nnpm run lint\n```\n\n### Test\n\n```bash\nnpm run test\n```\n\n### Test + Watch\n\n```bash\nnpm run test:watch\n```\n\n### Test + Coverage\n\n```bash\nnpm run coverage\n```\n\n## License\n\n[MIT License](./LICENSE)\n\nCopyright (c) Alex Milevski ([@w8r](https://github.com/w8r))\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw8r%2Fsegment-intersection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fw8r%2Fsegment-intersection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw8r%2Fsegment-intersection/lists"}