I know this question has been asked before, but the answers I have come across I need a little more help understanding how to implement. I came across this answer here, but the cited link does not appear to be valid anymore. Also searching elsewhere says it is not possible, or is very hard to find how to do this, or is so heavily filled with mathematical lingo, so please help!
https://math.stackexchange.com/q/302145
I have a cubic Bezier curve that passes through 6 points. The knowns are
t0 = 0, t5 = 1, P0 = xy0, P3 = xy5, xy0-xy5
Unknowns are
t1, t2, t3, t4, P1, P2
I know how to create the curve by merging two bezier curves each with 4 control points, but I only want one curve with 4 control points and I know it exists.
I have 8 unknown equations for t values and 2 control points. Can I solve this using matrices and how would I set it up?
C(t0) = po(1-t0)³ + p1(3*t0(1-t0)²) + p2(3*t0²(1-t0)) + p3(t0³) = x0, P0
C(t1) = po(1-t1)³ + p1(3*t1(1-t1)²) + p2(3*t1²(1-t1)) + p3(t1³) = x1
C(t2) = po(1-t2)³ + p1(3*t2(1-t2)²) + p2(3*t2²(1-t2)) + p3(t2³) = x2
C(t3) = po(1-t3)³ + p1(3*t3(1-t3)²) + p2(3*t3²(1-t3)) + p3(t3³) = x3
C(t4) = po(1-t4)³ + p1(3*t4(1-t4)²) + p2(3*t4²(1-t4)) + p3(t4³) = x4
C(t5) = po(1-t5)³ + p1(3*t5(1-t5)²) + p2(3*t5²(1-t5)) + p3(t5³) = x5, P3
I am implementing in code, so can use a solver, but need to know the beginning steps and logic and how I would go about solving in the right way.
Update 11/15
So I thought I would post my working code. I actually had 7 points, not 6. Its not the prettiest, as Im on time constraints, but it works. Thx Bubba. and the link is working for me now.
from scipy.optimize import fsolve
#define x0-x6 and y0-y6
def solveEquations(params):
t1,t2,t3,t4,t5,xp1,yp1,xp2, yp2 = params
t0 = 0
t6 = 1
return ( x0*(1-t1)**3 + xp1*(3*t1*(1-t1)**2) + xp2*(3*t1**2*(1-t1)) + x6*(t1**3) - x1,
x0*(1-t2)**3 + xp1*(3*t2*(1-t2)**2) + xp2*(3*t2**2*(1-t2)) + x6*(t2**3) - x2,
x0*(1-t3)**3 + xp1*(3*t3*(1-t3)**2) + xp2*(3*t3**2*(1-t3)) + x6*(t3**3) - x3,
x0*(1-t4)**3 + xp1*(3*t4*(1-t4)**2) + xp2*(3*t4**2*(1-t4)) + x6*(t4**3) - x4,
x0*(1-t5)**3 + xp1*(3*t5*(1-t5)**2) + xp2*(3*t5**2*(1-t5)) + x6*(t5**3) - x5,
y0*(1-t1)**3 + yp1*(3*t1*(1-t1)**2) + yp2*(3*t1**2*(1-t1)) + y6*(t1**3) - y1,
y0*(1-t2)**3 + yp1*(3*t2*(1-t2)**2) + yp2*(3*t2**2*(1-t2)) + y6*(t2**3) - y2,
y0*(1-t3)**3 + yp1*(3*t3*(1-t3)**2) + yp2*(3*t3**2*(1-t3)) + y6*(t3**3) - y3,
y0*(1-t4)**3 + yp1*(3*t4*(1-t4)**2) + yp2*(3*t4**2*(1-t4)) + y6*(t4**3) - y4,
)
t1,t2,t3,t4,t5,xp1,yp1,xp2, yp2 = fsolve(solveEquations, (.2,.4,.6,.7,.9,9,5,5,-8))
print xp1, yp1, xp2, yp2