Exemplo n.º 1
0
 public CoverObject(AreaToCover coverArea, MachineObject machine, Coordinates machinePosition, Coordinates direction)
 {
     CoverArea = coverArea;
     MachineObject = machine;
     MachinePosition = machinePosition;
     Direction = direction;
 }
Exemplo n.º 2
0
Arquivo: Methods.cs Projeto: MGajd/DP
        public static decimal GetDistance(Coordinates point1, Coordinates point2)
        {
            decimal x = point1.X - point2.X;
            decimal y = point1.Y - point2.Y;

            var power = Math.Pow((double)x, 2) + Math.Pow((double)y, 2);

            return Convert.ToDecimal(Math.Sqrt(power));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Use when area shape is rectange and starts at coordinates [0,0]
        /// </summary>
        /// <param name="coordinate">Coordinate oposite to [0,0]</param>
        public AreaToCover(Coordinates coordinate)
        {
            AreaToCoverID = World.AreaToCoverIDCounter++.ToString();

            CoordinateList = new List<Coordinates>();
            CoordinateList.Add(new Coordinates(0, 0));
            CoordinateList.Add(new Coordinates(coordinate.X, 0));
            CoordinateList.Add(coordinate);
            CoordinateList.Add(new Coordinates(0, coordinate.Y));

            Shape = coordinate.X == coordinate.Y ? Enumerations.Shape.square : Enumerations.Shape.rectangle;
        }
Exemplo n.º 4
0
Arquivo: Methods.cs Projeto: MGajd/DP
        internal static int GetCoordinatecIndex(List<Coordinates> coordinateList, Coordinates coordinates)
        {
            int counter = 0;
            foreach (Coordinates coor in coordinateList)
            {
                if (coor.X == coordinates.X && coor.Y == coordinates.Y)
                    return counter;
                else
                    counter++;
            }

            throw new Exception("Coordinates not found!");
        }
Exemplo n.º 5
0
        private string GetNearerAreaToCover(Coordinates position, string area1ID, string area2ID)
        {
            //TODO:minor check if all case-s + if-es are necesarry
            switch (WorldToCover.World.CoverDirection)
            {
                case Enumerations.CoverDirection.leftToRight:
                    if (VerticalPosition == Enumerations.VerticalPosition.down)
                    {
                        if (Helpers.Methods.GetDistance(position, WorldToCover.World.GetAreaByID(area1ID).LeftDown) - WorkingWidth/2 < Helpers.Methods.GetDistance(position, WorldToCover.World.GetAreaByID(area2ID).LeftDown) + WorkingWidth/2)
                            return area1ID;
                        else
                            return area2ID;
                    }

                    break;
                default:
                    //TODO:minor Implement othe cover direction decisionns
                    throw new NotImplementedException("Implement other cover direction decisionns");
            }
            return area1ID;
        }
Exemplo n.º 6
0
 //TODO: critical - implement constructors
 /// <summary>
 /// Use when straight width is covered.
 /// </summary>
 /// <param name="start">Starting coordinates (middle of the machine)</param>
 /// <param name="end">Ending coordniates (middle of the machine)</param>
 /// <param name="width">Width of covered strip</param>
 public CoveredSubArea(Coordinates start, Coordinates end, decimal width)
 {
 }
Exemplo n.º 7
0
        /// <summary>
        /// Define rectangular obstacle coordinates.
        /// </summary>
        /// <param name="coordinates1"></param>
        /// <param name="coordinates2"></param>
        public Obstacle(Coordinates coordinates1, Coordinates coordinates2)
        {
            ObstacleCoordinatesList = new List<Coordinates>();

            ObstacleCoordinatesList.Add(coordinates1);
            ObstacleCoordinatesList.Add(coordinates2);
        }
Exemplo n.º 8
0
 internal void ReverseCoordinates()
 {
     Coordinates tempCoordinates = StartingCoordinates;
     StartingCoordinates = EndingCoordinates;
     EndingCoordinates = tempCoordinates;
 }
Exemplo n.º 9
0
        /// <summary>
        /// Creates new line by copying system info of old CoverLine. Use when adding the same value to both coordinates.
        /// </summary>
        /// <param name="_oldCoverLine">CovwrLine to create new one.</param>
        /// <param name="xCoordinateAdd">Add value to x coordinate.</param>
        /// <param name="yCoordinateAdd">Add value to y coordinate.</param>
        public CoverLine(CoverLine _oldCoverLine, int xCoordinateAdd, int yCoordinateAdd,bool isDivide = false, string areaToCoverID = null)
        {
            StartingCoordinates = new Coordinates(_oldCoverLine.EndingCoordinates.X + xCoordinateAdd, _oldCoverLine.EndingCoordinates.Y + yCoordinateAdd);
            EndingCoordinates = new Coordinates(_oldCoverLine.StartingCoordinates.X + xCoordinateAdd, _oldCoverLine.StartingCoordinates.Y + yCoordinateAdd);

            IsDivide = isDivide;
            AreaToCoverID = areaToCoverID ?? _oldCoverLine.AreaToCoverID;
            MachineID = _oldCoverLine.MachineID;
            Status = Enumerations.CoverLineStatus.reserved;
        }
Exemplo n.º 10
0
 public CoveredSubArea(Coordinates cord1, Coordinates cord2)
 {
 }
Exemplo n.º 11
0
        /// <summary>
        /// Returns min Y for values between X an X + offset
        /// </summary>
        /// <param name="x">X Coordinate</param>
        /// <param name="offset"></param>
        /// <returns></returns>
        private decimal GetMinY(decimal x, decimal offset)
        {
            List<Coordinates> extendedCoordinatesList = new List<Coordinates>();
            Coordinates[] tempArray = new Coordinates[CoordinateList.Count];
            CoordinateList.CopyTo(tempArray);
            extendedCoordinatesList = tempArray.ToList();

            Coordinates previousCoordinate = CoordinateList.First();
            for (int i = CoordinateList.Count - 1; i > 0; i--)
            {
                if (CoordinateList[i].X < previousCoordinate.X)
                {
                    extendedCoordinatesList.Insert(0, new Coordinates(CoordinateList[i].X, CoordinateList[i].Y));
                    previousCoordinate = CoordinateList.First();
                }
                else
                    break;
            }

            if (345 > x && x > 344)
            {
                tempArray = null;
            }

            List<Coordinates> outerCoordinatesList = GetOuterPoints(extendedCoordinatesList, Helpers.Methods.GetMin(x, x + offset), Helpers.Methods.GetMax(x, x + offset));
            List<Coordinates> minMaxCoordinatesList = GetMinMaxCoordinates(outerCoordinatesList, x, offset);

            return minMaxCoordinatesList.OrderBy(a => a.Y).First().Y;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Returns max Y for values between X an X + offset
        /// </summary>
        /// <param name="x">X Coordinate</param>
        /// <param name="offset"></param>
        /// <returns></returns>
        private decimal GetMaxY(decimal x, decimal offset)
        {
            Coordinates[] tempArray = new Coordinates[CoordinateList.Count];
            List<Coordinates> reversedList = new List<Coordinates>();
            CoordinateList.CopyTo(tempArray);
            reversedList = tempArray.ToList();
            reversedList.Reverse();
            reversedList.Insert(0, new Coordinates(reversedList.Last().X, reversedList.Last().Y));

            List<Coordinates> outerCoordinatesList = GetOuterPoints(reversedList, Helpers.Methods.GetMin(x, x + offset), Helpers.Methods.GetMax(x, x + offset));
            List<Coordinates> minMaxCoordinatesList = GetMinMaxCoordinates(outerCoordinatesList, x, offset);

            return minMaxCoordinatesList.OrderBy(a => a.Y).Last().Y;
        }
Exemplo n.º 13
0
        private void DeleteCoordinatesBetween(Coordinates coorFrom, Coordinates coorTo, CoverLine newCoverLine, int coef = 1)
        {
            List<Coordinates> newCoordinates = AddNewIndexes(coorFrom, coorTo, newCoverLine, coef);
            RemoveRedundantCoordinates();

            int coorFomIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, newCoordinates.Last());
            int coorToIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, newCoordinates.First());

            DeleteCoordinatesBetweenIndexes(coorFomIndex, coorToIndex);
        }
Exemplo n.º 14
0
        private List<Coordinates> AddNewIndexes(Coordinates coorFrom, Coordinates coorTo, CoverLine newCoverLine, int coef)
        {
            List<Coordinates> returnCoordinates = new List<Coordinates>();

            int coorToIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, coorTo);
            returnCoordinates.Add(Helpers.Methods.LinearInterpolation(CoordinateList[GetSafeCoordinateListIndex(coorToIndex)], CoordinateList[GetSafeCoordinateListIndex(coorToIndex - 1)], newCoverLine.X + (newCoverLine.Width / 2) * coef));
            CoordinateList.Insert(coorToIndex, returnCoordinates.Last());

            int coorFromIndex = Helpers.Methods.GetCoordinatecIndex(CoordinateList, coorFrom);
            returnCoordinates.Add(Helpers.Methods.LinearInterpolation(CoordinateList[GetSafeCoordinateListIndex(coorFromIndex)], CoordinateList[GetSafeCoordinateListIndex(coorFromIndex + 1)], newCoverLine.X + (newCoverLine.Width / 2) * coef));
            CoordinateList.Insert(coorFromIndex + 1, returnCoordinates.Last());

            return returnCoordinates;
        }
Exemplo n.º 15
0
Arquivo: Methods.cs Projeto: MGajd/DP
 public static double GetCoveringTimeSeconds(Coordinates a, Coordinates b, decimal speed)
 {
     return (double)(GetDistance(a, b) / speed);
 }
Exemplo n.º 16
0
Arquivo: Methods.cs Projeto: MGajd/DP
        internal static Coordinates LinearInterpolation(Coordinates coordinates1, Coordinates coordinates2, decimal x)
        {
            decimal y;
            //if (coordinates1.y > coordinates2.y)
            //{
            //    Coordinates temp = coordinates1;
            //    coordinates1 = coordinates2;
            //    coordinates2 = temp;
            //}

            if (coordinates2.Y == coordinates1.Y)
                y = coordinates2.Y;
            else
                y = ((coordinates2.Y - coordinates1.Y) / (coordinates2.X - coordinates1.X)) * (x - coordinates1.X) + coordinates1.Y;

            //if (y < 0)
            //    y *= -1;
            return new Coordinates(x, y);
        }