Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineSegment intersection(with:) doesn't work #9

Closed
florentdouine opened this issue Jan 30, 2018 · 1 comment
Closed

LineSegment intersection(with:) doesn't work #9

florentdouine opened this issue Jan 30, 2018 · 1 comment

Comments

@florentdouine
Copy link

Hi,
It seems like there is an issue with the calcul used in intersection(with:) function.
If you try this small example, you won't find any intersect point whereas it actually exist

let lineA = LineSegment(a: CGPoint(x:187.5, y:108.873626373626), b: CGPoint(x:352.335164835165, y:108.873626373626))
let lineB = LineSegment(a: CGPoint(x:272.0, y:88.0), b: CGPoint(x:354.0, y:388.0))
let point = lineA.intersection(with: lineB) //return nil

geogebra-export

toineheuvelmans pushed a commit that referenced this issue Feb 2, 2018
Adjust allowed rounding error to fix line intersection ( issue #9 )
@toineheuvelmans
Copy link
Owner

Hi @florentdouine , thanks for pointing this out. I have committed a fix which is available in release 1.0.2.
The issue was caused by a very small rounding error in one of the functions that are called under the hood of intersection(with: ). It already allowed for a rounding error smaller than 1e-14, but I moved this to 1e-12. I must stretch here that the intent of Metron is to be accurately enough for UI and animation-related tasks, not for super exact geometry (therefore I chose to extend the CoreGraphics types, instead of introducing high-precision alternatives).
Thanks again for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants