Finding $y$ coordinate given $x$ coordinate of cubic bezier curve under restrictions over control points

Given a cubic bezier curve,

$P(t) = P_0(1-t)^3 + 3P_1t(1-t)^2 + 3P_2 t^2(1-t) + P_3 t^3$

where $P(t) = (x(t), y(t))$ and $P_i = (x_i, y_i)$.

$P_0$ and $P_3$ are end points and $P_1$ and $P_2$ are control points.

Assume that $P_0 = (0,0)$ and $P_3 = (K,K)$ for some $K \in \mathbb{R}^+$. $P_1$ and $P_2$ are constrained to lie in the square defined by $P_0$ and $P_3$ as opposite ends of its diagonal.

I have the $x(t)$ coordinate, say $x^*$. The problem is to find an explicit equation for the corresponding $y(t)$ in terms of $x^*$. This means that I want a function $g$ in $x$ only such that $y^* = g(x^*)$.

I am hoping that with the constraints on the control points an explicit equation can be derived for $y$ given $x^*$.

EDIT: We know $P_1$ and $P_2$.

Thanks.


I think deletoin $t$ beween $$x=3x_1t(1-t)^2+3x_2t^2(1-t)+kt^3$$ and $$y=3y_1t(1-t)^2+3y_2t^2(1-t)+kt^3$$ is very difficult, for power 3. As you see here

fixed $x_1$ and $x_2$

with changing $y_1$ and $y_2$ we have a family of curves which give us a differential equation. I think finding an equation of $x(t)$, $y(t)$, $y_1$ and $y_2$ with fixed $x_1$ and $x_2$ is impossible. In this case by deletion $y_1$ or $y_2$, differential equation is of first order and if delete both of them, so differential equation is of second order. Fnding Envelope maybe useful here.

I think add an extra point or ordain extra conditions, like condition on slops, areas, etc it will be possible to find an explicit solution. Otherwise numerical method should provide approximation solutions.


What you're asking is impossible. Look at the magenta curve in the answer from @MyGlasses. For some of the $x$ values, there are two corresponding values of $y$, so a relationship of the form $y = g(x)$ is clearly not possible.

You can place restrictions on $x_1$ and $x_2$ that ensure that the function $t \mapsto x(t)$ is monotone increasing, and this removes the problem. For example, requiring that $x_1 \le x_2$ will do the trick. Possibly, weaker conditions might work, too.

A step in the right direction (maybe) is to express the curve as an implicit equation of the form $h(x,y) = 0$. Once you have done this, then, conceivably, you might be able to solve for $y$ as a function of $x$, though this is not likely to be easy.

To derive an implicit equation, you have to eliminate the parameter $t$. There is a considerable body of knowledge about elimination, though most of it is lost in the mists of time. Look up terms like "resultant". A good place to start learning more would be these notes by Tom Sederberg. Section 17.6 tells you how to implicitize a cubic curve that's in Bezier form. The result will be an equation $h(x,y) = 0$, where is $h$ is a polynomial of degree 3 in $x$ and $y$. In principle, you could then use the cubic formulae to find an equation that gives $y$ as a function of $x$, but it would be a mess.

If you really need to find the $y$ corresponding to a given $x$, I would recommend using numerical methods. Any decent polynomial root-finder should work OK.

Another approach is to strongly restrict the locations of the curve's control points. If $x_1-x_0 = x_2 - x_1 = x_3 - x_2$, then the mapping $t \mapsto x(t)$ will be linear so it's easy to derive the inverse map $x \mapsto t$.