ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - pkinney/segseg_ex: Segment-segment intersection classifier and calculator for Elixir
Segment-segment intersection classifier and calculator for Elixir - pkinney/segseg_ex
Visit Site

GitHub - pkinney/segseg_ex: Segment-segment intersection classifier and calculator for Elixir

GitHub - pkinney/segseg_ex: Segment-segment intersection classifier and calculator for Elixir

Segment-Segment Intersection

Build Status Hex.pm Documentation

Calculates intersection type and location for two line segments.

Classification of segment-segment intersection

Installation

defp deps do
  [{:seg_seg, "~> 1.0"}]
end

Usage

Full Documentation

The SegSeg module provides a function intersection that calculates the intersection between two line segments and returns a tuple with three elements:

  1. Boolean true if the two segments intersect at all, false if they are disjoint
  2. An atom representing the classification of the intersection:
  • :interior - the segments intersect at a point that is interior to both
  • :vertex - the segments intersect at an endpoint of one or both segments
  • :edge - the segments are parallel, collinear, and overlap for some non-zero length
  • :disjoint - no intersection exists between the two segments
  1. A tuple {x, y} representing the point of intersection if the intersection is classified as :interior or :vertex, otherwise nil.

Examples

SegSeg.intersection({2, -3}, {4, -1}, {2, -1}, {4, -3}) #=> {true, :interior, {3.0, -2.0}}
SegSeg.intersection({-1, 3}, {2, 4}, {-1, 4}, {-1, 5}) #=> {false, :disjoint, nil}
SegSeg.intersection({1, 2}, {3, 0}, {2, 1}, {4, 2}) #=> {true, :vertex, {2, 1}}
SegSeg.intersection({-1, 0}, {0, 2}, {1, 4}, {-1, 0}) #=> {true, :edge, nil}

Float Precision Issues

It 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.

SegSeg.intersection({4, 3}, {4, 7}, {6.05, 9.05}, {3.95, 6.95}) #=> {true, :interior, {4.0, 6.999999999999998}}
SegSeg.intersection({4, 3}, {4, 7}, {6.05, 9.05}, {3.95, 6.95}, epsilon: true) #=> {true, :vertex, {4, 7}}

Tests

> mix test

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory