def fitBezierSimple(pts):
    T = [np.linalg.norm(pts[i]-pts[i-1]) for i in range(1,len(pts))]
    tsum = np.sum(T)
    T = [0] + T
    T = [np.sum(T[0:i+1])/tsum for i in range(len(pts))]
    T = [[t**3, t**2, t, 1] for t in T]
    T = np.array(T)
    M = np.array([[-1,  3, -3, 1],
                  [ 3, -6,  3, 0],
                  [-3,  3,  0, 0],
                  [ 1,  0,  0, 0]])
    T = T.dot(M)
    T = np.concatenate((T, np.array([[100,0,0,0], [0,0,0,100]])))
    # pts = np.vstack((pts, pts[0] * 100, pts[-1] * 100))
    C = np.linalg.lstsq(T, pts)
    return C[0]
dataset/ETHPy150Open google/roboto/scripts/lib/fontbuild/curveFitPen.py/fitBezierSimple/original