public void line_intersection_result() { var a = new Segment2(new Point2(0, -1), new Point2(0, 1)); var b = new Line2(new Point2(1, 1), new Vector2(1, 1)); var c = new Line2(new Point2(1, 1), new Vector2(0, 1)); var d = new Line2(new Point2(0, 0), new Vector2(0, 1)); Assert.Equal(new Point2(0, 0), a.Intersection(b)); Assert.Equal(null, a.Intersection(c)); Assert.Equal(a, a.Intersection(d)); }
public void intersection_same() { var a = new Segment2(new Point2(0, 0), new Point2(1, 1)); var b = new Segment2(new Point2(1, 1), new Point2(0, 0)); var res = a.Intersection(a); AreSpatiallyEqual(a, res); AreSpatiallyEqual(b, res); res = b.Intersection(b); AreSpatiallyEqual(a, res); AreSpatiallyEqual(b, res); res = a.Intersection(b); AreSpatiallyEqual(a, res); AreSpatiallyEqual(b, res); res = b.Intersection(a); AreSpatiallyEqual(a, res); AreSpatiallyEqual(b, res); }
public void intersection_within() { var a = new Segment2(new Point2(0, 0), new Point2(1, 1)); var b = new Segment2(new Point2(-.5, -.5), new Point2(2, 2)); var res = a.Intersection(b); Assert.Equal(a, res); res = b.Intersection(a); Assert.Equal(a, res); }
public void perpendicular_not_intersecting() { var a = new Segment2(new Point2(0, 1), new Point2(1, 0)); var b = new Segment2(new Point2(2, 2), new Point2(1, 1)); var res = a.Intersection(b); Assert.Null(res); res = b.Intersection(a); Assert.Null(res); }
public void intersection_cross_ends() { var a = new Segment2(new Point2(0, 0), new Point2(1, 1)); var b = new Segment2(new Point2(0.5, 1.5), new Point2(1, 1)); var res = a.Intersection(b); Assert.Equal(new Point2(1, 1), res); res = b.Intersection(a); Assert.Equal(new Point2(1, 1), res); }
public void intersection_overlap() { var a = new Segment2(new Point2(0, 0), new Point2(1, 1)); var b = new Segment2(new Point2(.5, .5), new Point2(2, 2)); var exp = new Segment2(new Point2(.5, .5), new Point2(1, 1)); var res = a.Intersection(b); Assert.Equal(exp, res); res = b.Intersection(a); Assert.Equal(exp, res); }
public static void segment_segment_intersection_result() { var a = new Segment2(A, B); var b = new Segment2(C, D); var forward = a.Intersection(b); var reverse = b.Intersection(a); forward.Should().NotBeNull(); forward.Should().Be(reverse); }
public void raw_intersection_result() { var a = new Segment2(new Point2(0, -1), new Point2(0, 1)); var b = new Ray2(new Point2(1, 1), new Vector2(1, 1)); var c = new Ray2(new Point2(1, 1), new Vector2(-1, -1)); var d = new Ray2(new Point2(0, 1), new Vector2(0, 1)); var e = new Ray2(new Point2(0, -1), new Vector2(0, -1)); var f = new Ray2(new Point2(0, 0), new Vector2(0, 3)); Assert.Equal(null, a.Intersection(b)); Assert.Equal(new Point2(0, 0), a.Intersection(c)); Assert.Equal(null, a.Intersection(new Ray2(new Point2(0, 2), new Vector2(0, 1)))); Assert.Equal(null, a.Intersection(new Ray2(new Point2(0, -2), new Vector2(0, -1)))); Assert.Equal(new Point2(0, 1), a.Intersection(d)); Assert.Equal(a, a.Intersection(d.GetReverse())); Assert.Equal(new Point2(0, -1), a.Intersection(e)); Assert.Equal(a, a.Intersection(e.GetReverse())); Assert.Equal(new Segment2(f.P, a.B), a.Intersection(f)); Assert.Equal(new Segment2(a.A, f.P), a.Intersection(f.GetReverse())); }
public static void segment_ray_intersection_result() { var a1 = new Segment2(A, B); var a2 = new Segment2(B, A); var b = new Ray2(C, D); var forward1 = a1.Intersection(b); var forward2 = a2.Intersection(b); var reverse1 = b.Intersection(a1); var reverse2 = b.Intersection(a2); forward1.Should().NotBeNull(); forward1.Should().Be(forward2); forward1.Should().Be(reverse1); forward1.Should().Be(reverse2); }
public static void line_segment_intersection_result() { var a1 = new Line2(A, B); var a2 = new Line2(B, A); var b1 = new Segment2(C, D); var b2 = new Segment2(D, C); var forward1 = a1.Intersection(b1); var forward2 = a2.Intersection(b2); var reverse1 = b1.Intersection(a1); var reverse2 = b2.Intersection(a2); forward1.Should().NotBeNull(); forward1.Should().Be(forward2); forward1.Should().Be(reverse1); forward1.Should().Be(reverse2); }