Example #1
0
        public static int SqrDistance( BoardLocation a, BoardLocation b )
        {
            int xdiff = ( a.location.x * Constants.BoardCellDiameter + a.offset.x - b.location.x * Constants.BoardCellDiameter - b.offset.x );
            int ydiff = ( a.location.y * Constants.BoardCellDiameter + a.offset.y - b.location.y * Constants.BoardCellDiameter - b.offset.y );

            return xdiff * xdiff + ydiff * ydiff;
        }
Example #2
0
        public static int OrthogonalDistance( BoardLocation a, BoardLocation b )
        {
            int xdiff = Math.Abs( a.location.x * Constants.BoardCellDiameter + a.offset.x - b.location.x * Constants.BoardCellDiameter - b.offset.x );
            int ydiff = Math.Abs( a.location.y * Constants.BoardCellDiameter + a.offset.y - b.location.y * Constants.BoardCellDiameter - b.offset.y );

            return xdiff + ydiff;
        }