def triangular_force(t_start, t_max, t_end, f_max):
    """
    Returns a triangular force:

            f_max at t_max
           /\
          /  \
         /    \
        /      \
    ----        -----
        |       |
        |       |__ t_end
        |__ t_start


    Parameters
    ----------
    t_start: float
        time where triangular force starts to raise
    t_max: float
        time where force reaches maximum
    t_end: float
        time where force is gone to zero again
    f_max: float
        maximum value of force

    Returns
    -------
    f: callable
        function f(t)
    """
    def f(t):
        if t_start < t <= t_max:
            return f_max * (t-t_start) / (t_max-t_start)
        elif t_max < t < t_end:
            return f_max * (1.0 - (t - t_max) / (t_end - t_max))
        else:
            return 0.0
    return f