Exemple #1
0
        /// <summary>
        /// Finds the least common sector between a set of <see cref="WorldPoint"/>s.
        /// </summary>
        /// <param name="points">The set of <see cref="WorldPoint"/>s.</param>
        /// <returns>A new <see cref="WorldPoint"/>, located at the origin of the least common sector.</returns>
        public static WorldPoint LeastCommonSector(params WorldPoint[] points)
        {
            if (points != null && points.Length > 0)
            {
                int[] x = new int[points.Length];
                int[] y = new int[points.Length];

                for (int i = 0; i < points.Length; i++)
                {
                    x[i] = points[i].X.Sector;
                    y[i] = points[i].Y.Sector;
                }

                int xSec = HMath.Min(x);
                int ySec = HMath.Min(y);

                return(new WorldPoint(new WorldCoordinate(xSec, 0), new WorldCoordinate(ySec, 0)));
            }
            else
            {
                Log.Error("couldn't find least common sector: WorldPoint array is null or 0-length");
            }

            return(WorldPoint.Zero);
        }