예제 #1
0
/**
 * Gets the biggest distance component (x or y) between the two given tiles.
 * Also known as L-Infinity-Norm.
 * @param t0 the start tile
 * @param t1 the end tile
 * @return the distance
 */

        public static uint DistanceMax(TileIndex t0, TileIndex t1)
        {
            uint dx = MathFuncs.Delta(TileX(t0), TileX(t1));
            uint dy = MathFuncs.Delta(TileY(t0), TileY(t1));

            return(Math.Max(dx, dy));
        }
예제 #2
0
/**
 * Gets the biggest distance component (x or y) between the two given tiles
 * plus the Manhattan distance, i.e. two times the biggest distance component
 * and once the smallest component.
 * @param t0 the start tile
 * @param t1 the end tile
 * @return the distance
 */

        public static uint DistanceMaxPlusManhattan(TileIndex t0, TileIndex t1)
        {
            uint dx = (uint)MathFuncs.Delta(TileX(t0), TileX(t1));
            uint dy = (uint)MathFuncs.Delta(TileY(t0), TileY(t1));

            return(dx > dy ? 2 * dx + dy : 2 * dy + dx);
        }
예제 #3
0
/**
 * Gets the Manhattan distance between the two given tiles.
 * The Manhattan distance is the sum of the delta of both the
 * X and Y component.
 * Also known as L1-Norm
 * @param t0 the start tile
 * @param t1 the end tile
 * @return the distance
 */

        public static uint DistanceManhattan(TileIndex t0, TileIndex t1)
        {
            var dx = (uint)MathFuncs.Delta(TileX(t0), TileX(t1));
            var dy = (uint)MathFuncs.Delta(TileY(t0), TileY(t1));

            return(dx + dy);
        }