private void DrawPolygon(SimplePolygon polygon)
        {
            var pointCollection = new PointCollection();
            foreach (var vertex in polygon.Vertices)
            {
                var position = vertex.Position;
                pointCollection.Add(new Point(position.X, position.Y));
            }

            var polygonImage = new Polygon()
            {
                Fill = Brushes.Pink,
                Stroke = Brushes.Black,
                StrokeThickness = 3,
                Points = pointCollection
            };

            mainCanvas.Children.Add(polygonImage);
        }
Exemplo n.º 2
0
        public SimplePolygon UnionWith(SimplePolygon other)
        {
            throw new NotImplementedException();

            if (!this.Overlaps(other))
            {
                throw new ArgumentException("Polygons must overlap.");
            }

            foreach (var edge1 in this.Edges)
            {
                foreach (var edge2 in other.Edges)
                {
                    if (edge1.Intersects(edge2))
                    {
                        var intersection = edge1.GetIntersection(edge2);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public bool Overlaps(SimplePolygon other)
        {
            foreach (var edge1 in this.Edges)
            {
                foreach (var edge2 in other.Edges)
                {
                    if (edge1.Intersects(edge2))
                    {
                        return(true);
                    }
                }
            }

            if (other.ContainsPoint(this.firstEdge.Origin.Position))
            {
                return(true);
            }
            if (this.ContainsPoint(other.firstEdge.Origin.Position))
            {
                return(true);
            }

            return(false);
        }
        public SimplePolygon UnionWith(SimplePolygon other)
        {
            throw new NotImplementedException();

            if (!this.Overlaps(other))
                throw new ArgumentException("Polygons must overlap.");

            foreach (var edge1 in this.Edges)
                foreach (var edge2 in other.Edges)
                    if (edge1.Intersects(edge2))
                    {
                        var intersection = edge1.GetIntersection(edge2);
                    }
        }
        public bool Overlaps(SimplePolygon other)
        {
            foreach (var edge1 in this.Edges)
                foreach (var edge2 in other.Edges)
                    if (edge1.Intersects(edge2))
                        return true;

            if (other.ContainsPoint(this.firstEdge.Origin.Position))
                return true;
            if (this.ContainsPoint(other.firstEdge.Origin.Position))
                return true;

            return false;
        }
        private void Init()
        {
            Vector2 v1 = new Vector2(1, 1), v2 = new Vector2(3, 1), v3 = new Vector2(2, 3);
            var vertices = new[] { v1, v2, v3 };
            var polygon1 = new SimplePolygon(vertices);

            planner = new MotionPlanner(new[] { polygon1 });

            Vector2 start = new Vector2(0.5, 0.5),
                    goal = new Vector2(3.5, 3.5);
            var path = planner.CalculatePath(start, goal);

            DrawPolygon(polygon1);
            DrawPath(path);
            DrawBox();

            ResizeToFitContent();
        }