gradientspace / geometry3Sharp

C# library for 2D/3D geometric computation, mesh algorithms, and so on. Boost license.
http://www.gradientspace.com
Boost Software License 1.0
1.71k stars 384 forks source link

Segment2d incorrect intersection with 0-length segment #137

Open Jtfinlay opened 4 years ago

Jtfinlay commented 4 years ago

Hit this interesting case with some specific coordinates when performing polygon intersections.

The following case came back as true when performing an intersection check. The second segment has no length, and the y values are clearly below those of the first segment.

Using v1.0.324

Segment2d s1 = new Segment2d(
                new Vector2d(56.6598662, 34.32530824),
                new Vector2d(58.18386662, 35.87470824));

Segment2d s2 = new Segment2d(
                new Vector2d(58.05, 34.1964),
                new Vector2d(58.05, 34.1964));

Console.WriteLine(s1.Intersects(s2));

Thanks, James