Esempio n. 1
0
    /// <summary>
    /// Get the minimum number of arc steps, in either direction, from this CardinalDirection to another.
    /// The steps are encoded in clockwise direction, so a negative result indicates stepping anticlockwise.
    /// </summary>
    /// <param name="facing">original direction</param>
    /// <param name="to">direction to rotate to</param>
    /// <returns>an int between -2 and 3 (inclusive)</returns>
    public static int GetArcMinimum(this CardinalDirection facing, CardinalDirection to)
    {
        var steps = facing.GetArcLinear(to);

        if (steps > 3)
        {
            return(3 - steps);
        }
        else
        {
            return(steps);
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Find the relative direction of this direction to another. Specifically, the other
 /// direction relative to this one.
 ///	note: for two directions A and B:
 ///     A.Turn(A.Cross(B)) = B
 /// </summary>
 /// <param name="facing">the direction for other to be found relative </param>
 /// <param name="other">an other direction</param>
 /// <returns>'other' relative to 'facing'</returns>
 public static RelativeDirection Cross(this CardinalDirection facing, CardinalDirection other)
 {
     return((RelativeDirection)facing.GetArcLinear(other));
 }