mathnet / mathnet-spatial

Math.NET Spatial
http://spatial.mathdotnet.com
MIT License
376 stars 132 forks source link

Fix Line2D.TryIntersect to pass nullable Point2D #187

Closed f-frhs closed 1 year ago

f-frhs commented 3 years ago

This pull-request is asking for help to solve #178.

The problem is that LineSegment2D.TryIntersect() always passes by reference Point2D of intersection, regardless of whether the two LineSegment2D actually have a valid intersection or not.

In my fix, LineSegment2D.TryIntersect() passes by ref Point2D?, which can indicate that there is no intersection. My fix used #111 as reference.

I'm not sure that this breaking change is acceptable or not. If there is another way to solve this, I'm happy to learn it.

I considered these fix-plans:

  1. Leave it as it is
  2. Pass by ref default(Point2D)
  3. Pass by ref Nullable<Point2D>
  4. Pass by ref Point2D.Null (kinda)
  5. Return Nullable<Point2D> instead of bool