/// <summary> /// Manhattans distance between specified ms1 and ms2. /// </summary> /// <returns> /// The manhattan distance between ms1 and ms2. /// </returns> /// <param name="ms1"> /// The first MapSquare. /// </param> /// <param name="ms2"> /// The second MapSquare. /// </param> public static double ManhattanDistance(MapSquare ms1, MapSquare ms2) { if (ms1 == null) { throw new ArgumentNullException("ms1"); } if (ms2 == null) { throw new ArgumentNullException("ms2"); } return Mathf.Abs(ms1.x - ms2.x) + Mathf.Abs(ms1.x - ms2.x); }
/// <summary> /// Distance between specified ms1 and ms2. /// </summary> /// <param name="ms1"> /// The first MapSquare. /// </param> /// <param name="ms2"> /// The second MapSquare. /// </param> /// <returns> /// The <see cref="double"/>. /// </returns> public static double Distance(MapSquare ms1, MapSquare ms2) { if (ms1 == null) { throw new ArgumentNullException("ms1"); } if (ms2 == null) { throw new ArgumentNullException("ms2"); } return Mathf.Sqrt(Mathf.Pow(ms1.x - ms2.x, 2) + Mathf.Pow(ms1.x - ms2.x, 2)); }