コード例 #1
0
 public MatrixAccessor(int width, int height, CoordinateOrder2D order, bool zeroIndexed = true)
 {
     this.width       = width;
     this.height      = height;
     this.order       = order;
     this.zeroIndexed = zeroIndexed;
 }
コード例 #2
0
    // Returns the array's start index based on the given coordinate order.
    // This is equivalent to getting the index at zero-based (0, 0).
    private int GetStartIndex(CoordinateOrder2D coordinateOrder)
    {
        int offset1 = GetStartOffsetFromDirection(coordinateOrder.GetDirectionFirst());
        int offset2 = GetStartOffsetFromDirection(coordinateOrder.GetDirectionSecond());

        return(offset1 + offset2);
    }
コード例 #3
0
    public static CoordinateOrder2D Rotate180(this CoordinateOrder2D e)
    {
        switch (e)
        {
        default:
        case CoordinateOrder2D.RightThenDown:
            return(CoordinateOrder2D.LeftThenUp);

        case CoordinateOrder2D.RightThenUp:
            return(CoordinateOrder2D.LeftThenDown);

        case CoordinateOrder2D.LeftThenDown:
            return(CoordinateOrder2D.RightThenUp);

        case CoordinateOrder2D.LeftThenUp:
            return(CoordinateOrder2D.RightThenDown);

        case CoordinateOrder2D.UpThenRight:
            return(CoordinateOrder2D.DownThenLeft);

        case CoordinateOrder2D.UpThenLeft:
            return(CoordinateOrder2D.DownThenRight);

        case CoordinateOrder2D.DownThenRight:
            return(CoordinateOrder2D.UpThenLeft);

        case CoordinateOrder2D.DownThenLeft:
            return(CoordinateOrder2D.UpThenRight);
        }
    }
コード例 #4
0
    public static Direction2D GetDirectionVertical(this CoordinateOrder2D e)
    {
        switch (e)
        {
        default:
        case CoordinateOrder2D.UpThenRight:
        case CoordinateOrder2D.UpThenLeft:
        case CoordinateOrder2D.RightThenUp:
        case CoordinateOrder2D.LeftThenUp:
            return(Direction2D.Up);

        case CoordinateOrder2D.DownThenRight:
        case CoordinateOrder2D.DownThenLeft:
        case CoordinateOrder2D.RightThenDown:
        case CoordinateOrder2D.LeftThenDown:
            return(Direction2D.Down);
        }
    }
コード例 #5
0
 // Returns the array's end index based on the given coordinate order.
 // This is equivalent to getting the index at zero-based (width-1, height-1).
 private int GetEndIndex(CoordinateOrder2D coordinateOrder)
 {
     return(GetStartIndex(coordinateOrder.Rotate180()));
 }