def calculate_onedimensional_distance(x, y, horizontal=True):
    """
    x and y are 2D positions.
    
    horizontal checks whether we measure horizontal or vertical distance.
    """
    x = list(x)
    y = list(y)
    x[0] = float(x[0])
    x[1] = float(x[1])
    y[0] = float(y[0])
    y[1] = float(y[1])
    if horizontal:
        return abs(x[0] - y[0])
    else:
        return abs(x[1] - y[1])
