Given n points:
p0, p1, p2, ..., pn;
How can I get the point c1, c2 so that the cubic bezier curve defined by
p0, c1, c2, pn
closest to the g
Khan's function uses two versions of t[i], where t[i] represents the guess for closest point on the approximation curve to input point p[i]. The first simply uses uniform t[i] = i/(N-1), the second uses chord length. Whilst I couldn't find Khan's function, I think this simply calculates the linear distance p[i] to p[i+1], set t[0] to 0, t[1] to the distance p[0] to p[1], t[2] to t[1] + distance p[1] to p[2], and so on. The divide by the last value to put everything in the range 0-1.