def METHOD_NAME(sample, out, vel):
    """Returns True if maximum deceleration is needed NOW to avoid
    violating position constraints."""
    # Keep going one cycle without any acceleration.
    next_out = out + (vel * 0.001) # Assume a 1 ms period.
    # v = v0 + at
    # 0 = v0 + at
    # t = v0/a
    seconds_to_stop = abs(vel) / params['maxa']
    # figure out which direction we need to accelerate in
    if vel > 0:
        accel_sign = -1
    else:
        accel_sign = 1
    # r = r0 + v0t + 1/2 at^2
    pos_at_stop = next_out + (vel * seconds_to_stop) + (accel_sign * 0.5 * params['maxa'] * math.pow(seconds_to_stop, 2))
    print("sample=%d, next_out=%.6f, vel=%.6f, seconds_to_stop=%.6f, pos_at_stop=%.6f, min=%.6f, max=%.6f" % \
            (sample, next_out, vel, seconds_to_stop, pos_at_stop, params['min'], params['max']))
    if pos_at_stop > (params['max'] * 1.01) or pos_at_stop < (params['min'] * 1.01):
        return True
    return False