def clamp(val, minVal=0.0, maxVal=1.0):
    """ clamp value between min and max

    :param val: value to clamp
    :type val: float 
    :param minVal: minimum value 
    :type minVal: float
    :param maxVal: maximum value
    :type maxVal: float
    :return: the clamped value
    :rtype: float
    """
    return max(minVal, min(val, maxVal))