{"id":13508255,"url":"https://github.com/pkinney/segseg_ex","last_synced_at":"2025-10-21T19:02:07.075Z","repository":{"id":57546573,"uuid":"55239486","full_name":"pkinney/segseg_ex","owner":"pkinney","description":"Segment-segment intersection classifier and calculator for Elixir","archived":false,"fork":false,"pushed_at":"2023-05-30T17:11:08.000Z","size":163,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-01T07:33:30.651Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/pkinney.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-04-01T14:46:12.000Z","updated_at":"2024-07-19T15:34:48.000Z","dependencies_parsed_at":"2024-01-08T19:22:10.102Z","dependency_job_id":null,"html_url":"https://github.com/pkinney/segseg_ex","commit_stats":{"total_commits":9,"total_committers":3,"mean_commits":3.0,"dds":"0.33333333333333337","last_synced_commit":"0186ece2fba073147b069ecdf3c4ba8dbe671da1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkinney%2Fsegseg_ex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkinney%2Fsegseg_ex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkinney%2Fsegseg_ex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkinney%2Fsegseg_ex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkinney","download_url":"https://codeload.github.com/pkinney/segseg_ex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246307582,"owners_count":20756473,"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":[],"created_at":"2024-08-01T02:00:50.424Z","updated_at":"2025-10-21T19:02:02.044Z","avatar_url":"https://github.com/pkinney.png","language":"Elixir","funding_links":[],"categories":["Geolocation"],"sub_categories":[],"readme":"# Segment-Segment Intersection\n\n![Build Status](https://github.com/pkinney/segseg_ex/actions/workflows/ci.yaml/badge.svg)\n[![Hex.pm](https://img.shields.io/hexpm/v/seg_seg.svg)](https://hex.pm/packages/seg_seg)\n[![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/seg_seg)\n\n\nCalculates intersection type and location for two line segments.\n\n![Classification of segment-segment intersection](http://i.imgbox.com/hO3zHfNR.png)\n\n## Installation\n\n```elixir\ndefp deps do\n  [{:seg_seg, \"~\u003e 1.0\"}]\nend\n```\n\n## Usage\n\n**[Full Documentation](https://hexdocs.pm/seg_seg/SegSeg.html)**\n\nThe `SegSeg` module provides a function `intersection` that calculates the\nintersection between two line segments and returns a tuple with three elements:\n\n1. Boolean `true` if the two segments intersect at all, `false` if they are\n   disjoint\n2. An atom representing the classification of the intersection:\n\n- `:interior` - the segments intersect at a point that is interior to both\n- `:vertex` - the segments intersect at an endpoint of one or both segments\n- `:edge` - the segments are parallel, collinear, and overlap for some non-zero\n  length\n- `:disjoint` - no intersection exists between the two segments\n\n3. A tuple `{x, y}` representing the point of intersection if the intersection\n   is classified as `:interior` or `:vertex`, otherwise `nil`.\n\n## Examples\n\n```elixir\nSegSeg.intersection({2, -3}, {4, -1}, {2, -1}, {4, -3}) #=\u003e {true, :interior, {3.0, -2.0}}\nSegSeg.intersection({-1, 3}, {2, 4}, {-1, 4}, {-1, 5}) #=\u003e {false, :disjoint, nil}\nSegSeg.intersection({1, 2}, {3, 0}, {2, 1}, {4, 2}) #=\u003e {true, :vertex, {2, 1}}\nSegSeg.intersection({-1, 0}, {0, 2}, {1, 4}, {-1, 0}) #=\u003e {true, :edge, nil}\n```\n\n## Float Precision Issues\n\nIt is possible that floating point math imprecision can cause incorrect results for certain inputs.  In situations where this may cause issues, an `epsilon` options is available.  When set to `true` intersection comparisons are made with a very small `epsilon` based on the minimum of the lengths of the provided segment times a very small number (currently 0.0000000001). `epsilon` can also be set to a specific number that will be used as the epsilon value. This eliminates most rounding error, but of course could cause false results in certain situations. This currently only effects `:vertex` results but might be expanded to `:edge` in the future.\n\n```elixir\nSegSeg.intersection({4, 3}, {4, 7}, {6.05, 9.05}, {3.95, 6.95}) #=\u003e {true, :interior, {4.0, 6.999999999999998}}\nSegSeg.intersection({4, 3}, {4, 7}, {6.05, 9.05}, {3.95, 6.95}, epsilon: true) #=\u003e {true, :vertex, {4, 7}}\n```\n\n## Tests\n\n```bash\n\u003e mix test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkinney%2Fsegseg_ex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkinney%2Fsegseg_ex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkinney%2Fsegseg_ex/lists"}