// Returns the total offset resulting from two given coordinates. // The directions used are defined by the coordinate order. private int GetOffsetFromCoordinates(int coord1, int coord2) { Direction2D dir1 = order.GetDirectionFirst(); Direction2D dir2 = order.GetDirectionSecond(); int coord1Offset = GetOffsetFromCoordinate(coord1, dir1); int coord2Offset = GetOffsetFromCoordinate(coord2, dir2); return(coord1Offset + coord2Offset); }
// 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); }