# Finding cubic bezier curve endpoints based on relationship between endpoints and a point on the curve.

I have the following information about a bezier curve:

• The curve begins at $x=0$ and ends at $x=1$.
• The curve has two control points each at the same height as their closest endpoints, one at $x=.25$ and one at $x=.75$.
• The curve can be represented by $$y(x,a,b)=(1-x)^3a+3(1-x)^2xa+3(1-x)x^2b+x^3b$$
• Some point $(x,y)$ resides on the curve.
• $a$ and $b$ are related, such that $b=f(a)$ and $a=f^{-1}(b)$
• $f$ is a piecewise linear function as pictured in an example below:

• $f$ is variable, however it is always increasing and passes both the vertical and horizontal line tests.

My goal is to find $a(x,y)$ given some point $(x,y)$ and the function $b=f(a)$.

I've tried solving the curve's equation for $a$, resulting in: $$a(b,x,y)=\frac{(2x-3)bx^2+y}{(x-1)^2(2x+1)}$$ However, substituting for $b$ results in $$a(b,x,y)=\frac{f(a(b,x,y))(2x-3)x^2+y}{(x-1)^2(2x+1)}$$ which is recursive.

While I would prefer not to estimate the result, if anyone has an accurate estimation method that would be very helpful.

• What kind of function is $f$? I doubt you can get any meaningful answer without some detail on that function.
– MvG
Commented May 19, 2015 at 0:37
• @MvG $f$ is a continually increasing linear piecewise function. It is a variable in this problem, however. See question edits. Commented May 19, 2015 at 1:08

Plugging the known point $(x,y)$ into the equation

$$\underbrace{\bigl((1-x)^3+3(1-x)^2x\bigr)}_\alpha a + \underbrace{\bigl(3(1-x)x^2+x^3\bigr)}_\beta b=y$$

That's the equation of a line in $a,b$-space. You can intersect that with each linear piece of your piecewise linear function. If you have

$$(\alpha a_i+\beta b_i-y)(\alpha a_{i+1}+\beta b_{i+1}-y)\le 0$$

then the linear segment from $(a_i,b_i)$ to $(a_{i+1},b_{i+1})$ will intersect the line, and will contribute one possible solution (except for the special case where you're counting segment endpoints twice for each adjacent linear piece, but they only contribute once).