Bézier curve from three different y values

52 Views Asked by At

So I want to graph the Bézier curve below, but all I can find on how to do it is if two of the points are on the same y coordinate. How would I do it for this? Would I have to create the bottom part of the parabola from two of the same y coordinates, then add another segment to make it look like the one below? (https://i.stack.imgur.com/Z5d46.jpg)

1

There are 1 best solutions below

0
On BEST ANSWER

Quadratic Bézier segment $S$ is defined by two endpoints $A$ and $C$ and one control point $B$:

\begin{align} S(t)&=A\,(1-t)^2+2\,B\,(1-t)\,t+C\,t^2 ,\quad t\in[0,1],\\ S(0)&=A,\quad S(1)=C . \end{align}

Given the coordinates of the two endpoints and any other point $P=S(\tau)$, $\tau\in(0,1)$,

\begin{align} P&=S(\tau)=A\,(1-\tau)^2+2\,B\,(1-\tau)\,\tau+C\,\tau^2, \end{align} the control point $B$ is found as

\begin{align} B&=\tfrac1{2\,\tau\,(1-\tau)}(P-A\,(1-\tau)^2-C\,\tau^2) . \end{align}

Dealing with the graphs of the form $y(x)=a_2\,x^2+a_1\,x+a_0$, the required parameter $\tau$ is found as \begin{align} \tau&=\frac{P_x-A_x}{C_x-A_x} . \end{align}

For example, given two endpoints $A=(0, 575)$, $C=(20,2375)$ and a third point $P=(15, 1025)$, we have

\begin{align} \tau&=\frac{15-0}{20-0}=0.75,\\ B&=(10, -925) . \end{align}

enter image description here