def cubicCurve(P, t):
    """Evaluated the cubic Bezier curve (given by control points P) at t"""
    return P[0] * (1 - t) ** 3 + 3 * P[1] * t * (1 - t) ** 2 + 3 * P[2] * (
    1 - t) * t ** 2 + P[3] * t ** 3