def calc_p1(p,p_p,p_m, i, cd):
    """Calculate the control point p1 of the current cubic Bezier curve."""
    if not i:
        x = p.x + ((p_p.x - p.x) / cd)
        y = p.y + ((p_p.y - p.y) / cd)
    else:
        x1 = -(p_m.x - p.x) / cd
        y1 = - (p_m.y - p.y) / cd
        x2 = (p_p.x - p.x) / cd
        y2 = (p_p.y - p.y) / cd
        x = p.x + (x1 + x2) / cd
        y = p.y + (y1 + y2) / cd
    return x, y