Beispiel #1
0
 public void AddUniqueRange(UOPositionCollection other)
 {
     foreach (UOPosition otherItem in other)
     {
         if (this.GetItemByPosition(otherItem) == null)
         {
             this.Add(otherItem);
         }
     }
 }
Beispiel #2
0
        public UOPositionCollection SortByDistanceToPosition(IUOPosition positionFrom)
        {
            UOPositionCollection sortedCol = new UOPositionCollection();

            sortedCol.AddRange(this.ToArray());

            sortedCol.Sort(delegate(UOPosition a, UOPosition b)
            {
                double distanceA = Robot.GetRelativeVectorLength(positionFrom, a);
                double distanceB = Robot.GetRelativeVectorLength(positionFrom, b);


                return(distanceA.CompareTo(distanceB));
            });

            return(sortedCol);
        }
Beispiel #3
0
        public UOPositionCollection SortByOptimalTrack(IUOPosition positionFrom)
        {
            IUOPosition          last      = positionFrom;
            UOPositionCollection sortedCol = new UOPositionCollection();

            for (int i = 0; i < this.Count; i++)
            {
                UOPositionCollection search = this.SortByDistanceToPosition(last);

                if (search.Count > 0)
                {
                    foreach (UOPosition pos in search)
                    {
                        if (!sortedCol.Contains(pos))
                        {
                            sortedCol.Add(pos);
                            last = pos;
                            break;
                        }
                    }
                }
            }
            return(sortedCol);
        }