Beispiel #1
0
        private BoolExpr handlePolygonalObstacle(PolygonalObstacle obstacle, Context ctx, IntExpr[] sourcesX, IntExpr[] sourcesY,
                                                 IntExpr[] destinationsX, IntExpr[] destinationsY)
        {
            List <LineSegment> segments      = obstacle.getLines();
            List <BoolExpr>    avoidingLines = new List <BoolExpr>();

            foreach (LineSegment segment in segments)
            {
                if (segment.isHorizontal)
                {
                    int leftX = (segment.start.x < segment.end.x ? segment.start.x : segment.end.x) - obstaclePassDistance;
                    int leftY = segment.start.y - obstaclePassDistance;
                    RectangularObstacle rectangle = new RectangularObstacle(2 * obstaclePassDistance,
                                                                            Coordinate.getXDistanceBetweenCoordinates(segment.start, segment.end) + 2 * obstaclePassDistance,
                                                                            new Coordinate(leftX, leftY));
                    avoidingLines.Add(handleRectangularObstacle(rectangle, ctx, sourcesX, sourcesY, destinationsX, destinationsY));
                }
                else if (segment.isVertical)
                {
                    int leftY = (segment.start.y < segment.end.y ? segment.start.y : segment.end.y) - obstaclePassDistance;
                    int leftX = segment.start.x - obstaclePassDistance;
                    RectangularObstacle rectangle = new RectangularObstacle(Coordinate.getYDistanceBetweenCoordinates(segment.start, segment.end)
                                                                            + 2 * obstaclePassDistance, 2 * obstaclePassDistance, new Coordinate(leftX, leftY));
                    avoidingLines.Add(handleRectangularObstacle(rectangle, ctx, sourcesX, sourcesY, destinationsX, destinationsY));
                }
                else
                {
                    avoidingLines.Add(handleCurvedLine(segment, ctx, sourcesX, sourcesY, destinationsX, destinationsY));
                }
            }

            return(ctx.MkAnd(ctx.MkAnd(avoidingLines.ToArray())));
        }
 private void drawPolygonalObstacle(PolygonalObstacle o)
 {
     Coordinate[] relLocs = new Coordinate[o.points.Count];
     for (int i = 0; i < o.points.Count; i++)
     {
         Coordinate c = calculateRelativeCanvasPosition(o.points[i]);
         relLocs[i] = c;
     }
     graphicsObj.DrawPolygon(obstaclePen, relLocs.Select(item => new Point(item.x, item.y)).ToArray());
 }
Beispiel #3
0
        private BoolExpr handlePolygonEndPoints(PolygonalObstacle obstacle, Context ctx, IntExpr[] sourcesX, IntExpr[] sourcesY,
                                                IntExpr[] destinationsX, IntExpr[] destinationsY)
        {
            List <BoolExpr>    avoidingEndPoints = new List <BoolExpr>();
            List <LineSegment> segments          = obstacle.getLines();

            foreach (LineSegment segment in segments)
            {
                RectangularObstacle first = new RectangularObstacle(obstaclePassDistance * 2, obstaclePassDistance * 2,
                                                                    new Coordinate(segment.start.x - obstaclePassDistance, segment.start.y - obstaclePassDistance));
                RectangularObstacle second = new RectangularObstacle(obstaclePassDistance * 2, obstaclePassDistance * 2,
                                                                     new Coordinate(segment.end.x - obstaclePassDistance, segment.end.y - obstaclePassDistance));
                avoidingEndPoints.Add(handleRectangularObstacle(first, ctx, destinationsX, destinationsY, sourcesX, sourcesY));
                avoidingEndPoints.Add(handleRectangularObstacle(second, ctx, destinationsX, destinationsY, sourcesX, sourcesY));
            }

            return(ctx.MkAnd(avoidingEndPoints.ToArray()));
        }