Is it possible to find the control points of a quadratic bezier curve, given the starting, ending and stationary point?

1.3k Views Asked by At

I know from this question on SO that it is possible to get the stationary point of a bezier curve given the control points, but I want to know wether the opposite is true:

If I have the start and end points of a Parabola, and I have the maximum point, is it possible to express this a quadratic bezier curve?

I have seen this answer explaining that you usually would need 6 points on a cubic to effectively describe a bezier curve, but looking at the question itself, it describes a few special cases where you can find the control points on a cubic, and I am curious on wether a quadratic bezier curve has such points, and wether a stationary point is one of them

The variable t of the stationary point is not avalible

I am coming from a computer science background, and although im not too weak in math, any answers/articles that don't use complicated maths and keep it simple would be appreciated

If this is not possible, would it help of the stationary point is always a maximum point and the x coordinate if the max point is the mean of the x coordinates of the start and end points?

By maximum point I mean the point with the maximum value for its y coordinate and by stationary I meant the point with the maximum or minimum value for y

2

There are 2 best solutions below

4
On BEST ANSWER

Define the following:

  • The quadratic Bézier has control points $(x_0,y_0)$ (start), $(x,y)$, $(x_2,y_2)$ (end)
  • The third known point is at $(x_1,y_1)$ with parameter $t$ (in this part of the answer, this is the point with extremal $y$-coordinate)

The curve's equation is then $$x(t)=(1-t)^2x_0+2t(1-t)x+t^2x_2\tag1$$ $$y(t)=(1-t)^2y_0+2t(1-t)y+t^2y_2\tag2$$ and the constraints are $x(t)=x_1$, $y(t)=y_1$ and $y'(t)=0$. Eliminating $y$ in the last two equations gives $$\Delta y_2t^2-2\Delta y_1t+\Delta y_1=0\qquad(\Delta c_i=c_0-c_i)$$ $$t=a\pm\sqrt{a(a-1)},a=\frac{\Delta y_1}{\Delta y_2}\qquad(\Delta y_2\ne0)$$ $$\Delta y_2=0\implies t=\frac12$$ There is a solution in general iff $a\not\in(0,1)$ and only one choice of sign will give $t\in[0,1]$. Once $t$ has been found, it may be substituted back into $(1)$ and $(2)$ to find $x$ and $y$ respectively.


If $(x_1,y_1)$ is the parabola's vertex, the third equation may be obtained from this diagram:

The curve's tangent at the vertex is perpendicular to the line passing between the midpoint of the curve endpoints and the third control point, i.e. $$\begin{bmatrix}\frac{x_0+x_2}2-x\\\frac{y_0+y_2}2-y\end{bmatrix}\cdot\begin{bmatrix}x'(t)\\y'(t)\end{bmatrix}=0$$

A resultant computation followed by factoring out bogus solutions then shows that $t$ solves the cubic $$\begin{align} (\Delta x_2^2+\Delta y_2^2)&t^3\\ -3(\Delta x_1\Delta x_2+\Delta y_1\Delta y_2)&t^2\\ +(\Delta x_1(2\Delta x_1+\Delta x_2)+\Delta y_1(2\Delta y_1+\Delta y_2))&t\\ -(\Delta x_1^2+\Delta y_1^2)&=0 \end{align}$$

4
On

Let $P_0$ and $P_2$ be startpoint and endpoint of a quadratic Bézier curve. If by "maximum point" you mean that point $Q$ on the curve which is at the maximum distance from line $AB$ (this is not the same as the vertex of the parabola, in general), then finding the control point $P_1$ is easy, because $Q$ is the midpoint between $P_1$ and the midpoint $M$ of $AB$.

Note that the tangent to the curve at $Q$ is parallel to $AB$ and $Q$ is obtained by substituting $t=1/2$ in the equation of the curve: $$ B(t)=(1-t)^{{2}}P_{0}+2t(1-t)P_{1}+t^{{2}}P_{2}. $$

enter image description here

EDIT.

After the given clarifications by the OP, let's assume that the stationary point $P=(x,y)$ of the curve (having $dy/dt=0$) is also known, in addition to $P_0$ and $P_2$. We can simplify a bit the computation shifting all points with a translation so that $P_0=(0,0)$ (this can of course be undone at the end with the opposite translation). In this case we have then: $$ (x,y)=2t(1-t)(x_1,y_1)+t^2(x_2,y_2). $$ The condition $dy/dt=0$ gives $ty_2+(1-2t)y_1=0$, which can be solved for $y_1$: $$ y_1={t\over2t-1}y_2. $$ We can insert this into the equation for $y$, which becomes then $t^2y_2=y(2t-1)$ and can be solved for $t$: $$ t={y\pm\sqrt{y^2-y_2y}\over y_2}. $$ Note that the sign must be chosen so that $0<t<1$, and this can happen only if $\min(0,y2)<y<\max(0,y2)$, as it was to be expected, and $y_2\ne0$ (but see below for this case).

We can substitute this into the equations for $y_1$ given above and into $$ x_1={x-t^2x_2\over2t(1-t)} $$ to obtain the coordinates of control point $P_1$.

Finally, if $y_2=0$ the above solution is singular, but only apparently, because that is exactly the case discussed in the first part of my answer. Hence we can find at once the solution if $y_2=0$: $$ y_1=2y,\quad x_1=2x-{1\over2}x_2. $$