def cubic_bezier(p0, p1, p2, p3, t):
    """ evaluate cubic bezier curve from p0 to p3 at fraction t for control points p1 and p2 """
    return p0 * (1 - t)**3 + 3 * p1 * t*(1 - t)**2 + 3 * p2 * t**2*(1 - t) + p3 * t**3