import math


def bezier(p1, p2, p0=(0,0), nt=20):
    """
        A method which creates a Bézier curve between points p1 and p2 with control point p0.

        Parameter(s):
        -------------
        p1 : Tuple 
            point p1, given by x & y coordinates (x1, y1).
        p2 : Tuple 
            point p2, given by x & y coordinates (x2, y2).
        p0 : Tuple 
            point p0, given by x & y coordinates (x0, y0). Default is (0, 0).
        nt : Integer
            Number of intermediate points to create the curve. Default is 20.

        Returns:
        --------
        bezier : Dict
            Dictionary of x and y coordinates of the created Bézier curve.
    """
    bezier = {}
    bezier['x'] = [] # x values of bezier curve points
    bezier['y'] = [] # y values of bezier curve points
    # for each point along the curve.
    for i in range(0, nt+1):
        t = (1/nt) * i # curve point index 't'.
        bezier['x'].append(
            (p1['x']-2*p0[0]+p2['x'])*math.pow(t,2) + 2*t*(p0[0]-p1['x']) + p1['x']
        ) # append x value of curve point 't'.
        bezier['y'].append(
            (p1['y']-2*p0[0]+p2['y'])*math.pow(t,2) + 2*t*(p0[0]-p1['y']) + p1['y']
        ) # append y value of curve point 't'.
    return bezier