コード例 #1
0
        public void PointOutsidePolygonLeft()
        {
            // Arrange
            PointF point1 = new PointF(-1F, 2F);

            PointF[] polygon = new PointF[] {
                new PointF(0F, 0F),
                new PointF(0F, 8F),
                new PointF(4F, 4F),
                new PointF(9F, 7F),
                new PointF(13F, 0F),
            };
            // Act
            bool answer = IsPointInsideOrOutsidePolygon.IsPointInPolygon(polygon, point1);

            // Assert
            Assert.AreEqual(false, answer);
        }
コード例 #2
0
        public void PointOnBottomBorderOfPolygon()
        {
            // Arrange
            PointF point1 = new PointF(4F, 0F);

            PointF[] polygon = new PointF[] {
                new PointF(0F, 0F),
                new PointF(0F, 8F),
                new PointF(4F, 4F),
                new PointF(9F, 7F),
                new PointF(13F, 0F),
            };
            // Act
            bool answer = IsPointInsideOrOutsidePolygon.IsPointInPolygon(polygon, point1);

            // Assert
            Assert.AreEqual(true, answer);
        }
コード例 #3
0
        public void PointOutsidePolygonWithSelfIntersections()
        {
            // Arrange
            PointF point1 = new PointF(-1F, 2F);

            PointF[] polygon = new PointF[] {
                new PointF(3F, 0F),
                new PointF(2F, -1F),
                new PointF(1F, 3F),
                new PointF(-3F, 0F),
                new PointF(-2F, 2F),
                new PointF(-1F, 0F),
                new PointF(0F, 4F),
                new PointF(1F, 0F),
                new PointF(2F, 2F),
            };
            // Act
            bool answer = IsPointInsideOrOutsidePolygon.IsPointInPolygon(polygon, point1);

            // Assert
            Assert.AreEqual(false, answer);
        }