def blendTriangular(d, u=0.1, s=0.4, c=0.9):
    """
    Triangular blending funciton, taken from eq. 3.5
    
    c must be greater than s
    s must be greater than u
    u is the beginning point of the triangle
    c is the endpoint of the triangle
    s is the peak of the triangle
    """
    d = float(d)
    u = float(u)
    s = float(s)
    c = float(c)

    if (s - u) == 0:
        return 0
    if (c - s) == 0:
        return 0
    
    if d <= u: 
        b = 0.0
    elif d > u and d <= s:
        b = (d - u)/(s - u)
    elif d > s and d < c:
        b = (c - d)/(c - s)
    else: 
        b = 0.0
    return b