Exemplo n.º 1
0
        /// <summary>
        /// Calc minimum distance for the same terrain types items (by terrain type)
        /// </summary>
        /// <param name="TT"></param>
        /// <returns></returns>
        public double GetNearestSameTerrainTypeMinDistance(TerrainType TT)
        {
            List <FieldElement> ItemsList;

            ItemsList = GetItemsByTerrainType(TT);

            var minDist = 100.0;

            foreach (var item in ItemsList)
            {
                FieldElement Nearest = GetNearestSameTerrainType(item);
                var          dist    = CalcDistance(item, Nearest);
                if (dist < minDist)
                {
                    minDist = dist;
                }
            }

            return(minDist);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Search for nearest item with the same terrain type
        /// </summary>
        /// <param name="AnalyzedFieldItem"></param>
        /// <returns></returns>
        public FieldElement GetNearestSameTerrainType(FieldElement AnalyzedFieldItem)
        {
            var          dist     = 0.0;
            var          mindist  = 1000.0;
            FieldElement retField = AnalyzedFieldItem;

            for (int i = 0; i < 18; i++)
            {
                if (FieldItems[i].Type == AnalyzedFieldItem.Type && AnalyzedFieldItem.id != i)
                {
                    dist = CalcDistance(AnalyzedFieldItem, FieldItems[i]);
                    if (dist < mindist)
                    {
                        mindist  = dist;
                        retField = FieldItems[i];
                    }
                }
            }
            return(retField);
        }
Exemplo n.º 3
0
 public double CalcDistance(FieldElement P1, FieldElement P2)
 {
     return(CalcDistance(P1.Coord, P2.Coord));
 }