1

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.

Dhruv Kohli
  • 5,216
  • you want an explicit equation of $x(t)$, $y(t)$, $y_1$, $y_2$ which is include parameter $t$.? – Nosrati Feb 03 '17 at 08:50
  • I want $y$ as a function of $x$ without $t$. – Dhruv Kohli Feb 03 '17 at 09:17
  • $x_1=x_2=x^*$.? – Nosrati Feb 03 '17 at 09:23
  • No. $x_i \neq x(i)$. However, by putting $t=0$ in the equation you'll get $P(0) = P_0$ which means $(x(0),y(0)) = (x_0,y_0)$ and $P(1) = P_3$ which means $(x(1),y(1)) = (x_3,y_3)$ – Dhruv Kohli Feb 03 '17 at 09:41
  • Even with $x_1=x_2=x^$, I think finding a equation of $x(t)$, $y(t)$, $x^$, $y_1$ and $y_2$ is impossible. – Nosrati Feb 03 '17 at 09:42
  • Can you elaborate? – Dhruv Kohli Feb 03 '17 at 09:45
  • That's great. Thanks a lot. – Dhruv Kohli Feb 03 '17 at 10:03
  • The same question was asked here: http://math.stackexchange.com/questions/26846/is-there-an-explicit-form-for-cubic-b%C3%A9zier-curves. – bubba Feb 05 '17 at 12:24
  • I already went through that link. I don't want an iterative root finding solution. Computing the root of the cubic equation to obtain $t$ and then putting it in the parameteric equation of $y(t)$ to obtain $y^$ was the only solution that I found relevant to my context. However, I had to code that solution symbolically. And fortunately I was able to do that correctly because of the restrictions that I have over the control points. So, basically, I now have a symbolic code that computes the root of $x(t)=x^$ and then computes $y^*=y(t)$ using the obtained root $t$. – Dhruv Kohli Feb 06 '17 at 06:07
  • Would you mind sharing your solution? I'm looking for the same code that computes the root of x(t) = x, computing y = y(t) using the obtained root t – Valerie Jul 23 '21 at 00:12

2 Answers2

2

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.

Nosrati
  • 29,995
2

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$.

bubba
  • 43,483
  • 3
  • 61
  • 122
  • 1
    Thanks a lot for your answer. I will go through the notes. However, I now have the solution I needed. Please have a look at my comment above. – Dhruv Kohli Feb 06 '17 at 06:10