Calculate quad curve control point from on-curve point

bezier-curvegeometry

I'm trying to calculate the control point of a quad curve (I know the start and end points) so that it passes through a given point. Here is an image to help you see what I'm doing:

https://i.sstatic.net/eFvyb.png

My goal is to find the x position of the green control point. I know the y because it is always on the blue horizontal line.

So basically I know the start and end points of the curve and I know one on-curve point (red circle). I also know what the y of green control point is. I just need to know the x of the green control point so that the red circle is on the curve.

Any help would be greatly appreciated 🙂

Best Answer

Given a quadratic Bezier curve

$$ b_2(p_0,p_1,p_2,t) = (1-t)((1-t)p_0+t p_1)+t((1-t)p_1+t p_2),\ \ 0\le t\le 1 $$

we have the control point as $p_1$ now the question is. Where locate $p_1$ such that the spline passes by $p_0,q,p_2$?

we have for a suitable set $\{t^*, p_1^*\}$ that

$$ b_2(p_0,p_1^*,p_2,t^*) = q $$

so fixing a $0\le t^* \le 1$ and giving a desired $q$ we can determine the control point $p_1^*(t^*)$ by solving

$$ (1-t^*)((1-t^*)p_0+t^* p_1^*)+t^*((1-t^*)p_1^*+t^* p_2) = q $$

Attached a plot showing the case

$$ q = (0.8,0.6) \ \ \mbox{red}\\ p_0 = (0,2) \ \ \mbox{red}\\ p_1^* = (1.66667,0.416667) \ \ \mbox{green}\\ p_2 = (0,-2) \ \ \mbox{red}\\ t^* = 0.4 $$

enter image description here

NOTE

Be aware that $p_1^* = p_1^*(t^*)$