Пример #1
0
 public double distanceFrom(Coordinates original)
 {
     double x = Math.Pow((original.x - this.x),2);
     double y = Math.Pow((original.y - this.y),2);
     double xy = x + y;
     return (Math.Pow(xy,0.5));
 }
Пример #2
0
        //TODO any graphical show
        public void getBorder()
        {
            System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.MediumOrchid, 1);
            boxes = (from a in boxes
                            orderby (a.coordinates.y), (a.coordinates.x)
                            select a).ToList();
            bool border = true;
            int minX = boxes[0].coordinates.x;
            int minY = boxes[0].coordinates.y;
            int maxX = boxes[boxes.Count - 1].coordinates.x;
            int maxY = boxes[boxes.Count - 1].coordinates.y;
            int upperBorderline = minX;
            int lowerBorderline = maxY;
            int leftBorderline = minY;
            int rightBorderline = maxX;
            foreach (Box box in boxes)
            {
                if (box.coordinates.y == minY)
                {
                    if (upperBorderline == box.coordinates.x)
                    {
                        upperBorderline += box.width;
                    }
                    else
                    {
                        //TODO any graphical show
                    }
                }
                //TODO orientation
                if (box.coordinates.y == maxY)
                {
                    if (lowerBorderline == box.coordinates.x)
                    {
                        lowerBorderline += box.width;
                    }
                    else
                    {
                        //TODO any graphical show
                    }
                }
                if (box.coordinates.x == minX)
                {
                    if (leftBorderline == box.coordinates.y)
                    {
                        leftBorderline += box.height;
                    }
                    else
                    {
                        //TODO any graphical show
                    }
                }
                //TODO orientation
                if (box.coordinates.x == maxX)
                {
                    if (rightBorderline == box.coordinates.x)
                    {
                        rightBorderline += box.height;
                    }
                    else
                    {
                        //TODO any graphical show
                    }
                }
            }
            if (lowerBorderline != maxX + Configuration.boxWidth || upperBorderline != maxX + Configuration.boxWidth || leftBorderline != maxY + Configuration.boxHeight || rightBorderline != maxY + Configuration.boxHeight)
                border = false;
            unifiedBorder = border;
            if (border)
                borderLimits = new Coordinates(upperBorderline, leftBorderline);
            else
                borderLimits = new Coordinates(Configuration.palletWidth, Configuration.palletHeight);

            minX += Configuration.startX;
            minY += Configuration.startY;
            maxX += Configuration.startX + boxes[boxes.Count - 1].width;
            maxY += Configuration.startY + boxes[boxes.Count - 1].height;

            formGraphics.DrawLine(pen, minX, minY, minX, maxY);
            formGraphics.DrawLine(pen, minX, minY, maxX, minY);
            formGraphics.DrawLine(pen, maxX, minY, maxX, maxY);
            formGraphics.DrawLine(pen, minX, maxY, maxX, maxY);
        }
Пример #3
0
 public void getCenterOfGravity()
 {
     Coordinates coordinates = new Coordinates();
     double x = 0;
     double y = 0;
     foreach (Box box in boxes) {
         x = x + (box.width) / 2 + box.coordinates.x;
         y = y + (box.height) / 2 + box.coordinates.y;
     }
     x = x / boxes.Count;
     y = y / boxes.Count;
     //TODO some control would be nice
     coordinates.x = Configuration.startX + (int)Math.Round(x);
     coordinates.y = Configuration.startY + (int)Math.Round(y);
     boxesCenterOfGravity = coordinates;
 }