Esempio n. 1
0
        private void drawEllipticalObstacle(EllipticalObstacle o)
        {
            Coordinate relLoc = calculateRelativeCanvasPosition(new Coordinate(o.location.x - o.width / 2,
                                                                               o.location.y - o.length / 2));
            Rectangle rectangle = new Rectangle(relLoc.x, relLoc.y, o.width, o.length);

            graphicsObj.DrawEllipse(obstaclePen, rectangle);
            graphicsObj.FillEllipse(brush, rectangle);
        }
Esempio n. 2
0
        private BoolExpr handleEllipticalObstacle(EllipticalObstacle obstacle, Context ctx, IntExpr[] destinationsX,
                                                  IntExpr[] destinationsY, IntExpr[] sourcesX, IntExpr[] sourcesY)
        {
            if (obstacle.length != obstacle.width)
            {
                RectangularObstacle rectangle = new RectangularObstacle(obstacle.length, obstacle.width,
                                                                        new Coordinate(obstacle.location.x - obstacle.width / 2, obstacle.location.y - obstacle.length / 2));
                return(handleRectangularObstacle(rectangle, ctx, sourcesX, sourcesY, destinationsX, destinationsY));
            }
            else
            {
                BoolExpr[]       avoidingCircle = new BoolExpr[pathSegments];
                NumberFormatInfo dot            = new NumberFormatInfo();
                dot.NumberDecimalSeparator = ".";
                for (int i = 0; i < pathSegments; i++)
                {
                    double    radius          = obstacle.length / 2.0 + obstaclePassDistance;
                    int       translateX      = obstacle.location.x;
                    int       translateY      = obstacle.location.y;
                    IntExpr   dist            = ctx.MkInt((int)radius);
                    ArithExpr adjustedSourceX = ctx.MkSub(sourcesX[i], ctx.MkInt(translateX));
                    ArithExpr adjustedSourceY = ctx.MkSub(sourcesY[i], ctx.MkInt(translateY));
                    ArithExpr adjustedDestX   = ctx.MkSub(destinationsX[i], ctx.MkInt(translateX));
                    ArithExpr adjustedDestY   = ctx.MkSub(destinationsY[i], ctx.MkInt(translateY));

                    ArithExpr dx   = ctx.MkSub(adjustedDestX, adjustedSourceX);
                    ArithExpr dy   = ctx.MkSub(adjustedDestY, adjustedSourceY);
                    ArithExpr dr_2 = ctx.MkAdd(ctx.MkMul(dx, dx), ctx.MkMul(dy, dy));
                    ArithExpr D    = ctx.MkSub(ctx.MkMul(adjustedSourceX, adjustedDestY), ctx.MkMul(adjustedDestX, adjustedSourceY));

                    ArithExpr incidence = ctx.MkSub(ctx.MkMul(ctx.MkMul(dist, dist), dr_2), ctx.MkMul(D, D));
                    BoolExpr  final     = ctx.MkLe(incidence, ctx.MkInt(0));
                    avoidingCircle[i] = final;
                }
                return(ctx.MkAnd(avoidingCircle));
            }
        }