Intersection of Bezier Cubic Curve with a "point".

230 Views Asked by At

How can I calculate "y3" so that the curve passes through point "A" ? With the equation for a Bezier Cubic Curve and my point A, I have :

$ y1(1-t)^3 + 3y2(1-t)^2t + 3y3(1-t)t^2 + y4t^2=ya $

But the root for "t" of this equation gives me an incredibly complicated and long solution. Is there a simpler solution?

See my draw.

Thanks. Nicolas.

My draw

1

There are 1 best solutions below

1
On

The problem that you appear to be setting is just a tiny bit more complicated than the solution you describe. In order to have the point $(x_a,y_a)$ on the curve, not only must your equation for $y$ give you $y_a$ at a certain value of $t,$ it must give $x_a$ at the same value of $t.$ So you are actually asking to solve two simultaneous equations, \begin{align} x_1(1-t^3) + 3x_2(1-t^2)t + 3x_3(1-t)t^2 + x_4 t^3 &= x_a, \tag1\\ y_1(1-t^3) + 3y_2(1-t^2)t + 3y_3(1-t)t^2 + y_4 t^3 &= y_a, \tag2\\ \end{align} where all the parameters except $t$ and $y_3$ are predetermined.

So one approach would be to solve for $t$ in Equation $1,$ which is a cubic equation in $t,$ then plug this value of $t$ into Equation $2$ and solve for $y_3.$ Equation $2$ is linear in $y_3,$ so it's easy; Equation $1$ is the difficult one.

If you have an especially fortunate choice of $x_a,$ you might be able to factorize Equation $1$ or even guess a solution. For example, if $x_1=x_2$ and $x_3=x_4$ (as they appear to be in the diagram) and if $x_a$ is exactly midway between $x_2$ and $x_3,$ then the solution is $t=\frac12.$ But in other cases there is a long, tedious procedure (or a big complicated formula) to find a solution. If there were a simpler way to solve this equation in general, it would already be in the textbooks.

An alternative, if you are programming this in a computer, is to apply numeric methods to find an approximate solution (which is what you will eventually get anyway if you need to plot this). Numeric methods come down to trial and error ("guess and check"), with various ways of making the guesses. The midpoint method is easy and probably effective enough if you don't need to solve thousands of problems like this.