コード例 #1
0
        public void IsInsidePolygon_WhenGivenAPointInside_ShouldReturnTrue()
        {
            var point = new Vector2();

            var face = new[]
            {
                new Vector2(-5, 5),
                new Vector2(5, 5),
                new Vector2(5, -5),
                new Vector2(-5, -5),
            };

            var inside = helper.IsInsidePolygon(point, face);

            Assert.True(inside);
        }
コード例 #2
0
        private void ResizeFace(IPlantCell aCell, IPlantCell bCell)
        {
            var aGeo  = aCell.Geometry;
            var aFace = aGeo.Face.Points;

            var bGeo  = bCell.Geometry;
            var bFace = bGeo.Face.Points;

            var pairs = geometryHelper.CreateFacePairs(bFace);

            for (int i = 0; i < aFace.Length; i++)
            {
                if (!geometryHelper.IsInsidePolygon(aFace[i], bFace))
                {
                    continue;
                }

                Vector2 nearest = FindNearestPoint(aFace[i], pairs);

                Vector2 direction = (aFace[i] - nearest) * aCell.Turgidity;

                aFace[i] = nearest;

                ChangeFace(aGeo, aFace[i], direction);
            }
        }
コード例 #3
0
        private bool IsInsidePolygon(Vector2[] aFace, Vector2[] bFace)
        {
            for (int i = 0; i < aFace.Length; i++)
            {
                if (helper.IsInsidePolygon(aFace[i], bFace))
                {
                    return(true);
                }
            }

            return(false);
        }