コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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()));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
ファイル: Segment2Facts.cs プロジェクト: aarondandy/vertesaur
 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);
 }
コード例 #14
0
ファイル: Segment2Facts.cs プロジェクト: aarondandy/vertesaur
 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);
 }
コード例 #15
0
ファイル: Segment2Facts.cs プロジェクト: aarondandy/vertesaur
 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);
 }
コード例 #16
0
ファイル: Segment2Facts.cs プロジェクト: aarondandy/vertesaur
 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);
 }
コード例 #17
0
ファイル: Segment2Facts.cs プロジェクト: aarondandy/vertesaur
        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));
        }
コード例 #18
0
ファイル: Segment2Facts.cs プロジェクト: aarondandy/vertesaur
        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()));
        }
コード例 #19
0
        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);
        }
コード例 #20
0
ファイル: Segment2Facts.cs プロジェクト: aarondandy/vertesaur
 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);
 }