Find the control point of a quadratic bezier curve with known maximum curve value

I have a quadratic Bézier curve which starts at $P0(5,10)$ and ends at $P2(7,0)$. I know that the maximum x-value of the curve is supposed to be at $x = 10$ and that the y-value of the control point $P1$ is at $y_{P1} = \frac{y_{P0}-y_{P2}}{2} = 5$.

How do I find $x_{P1}$ given these information?

The formula for quadratic bezier curves is (according to Wikipedia): $B(t) = (1-t)^2P0 + 2(1-t)tP1 + t^2P2$

I know that one can calculate $t$ at the maximum x-value of the curve as: $t_{x(max)} = \frac{x_{P0}-x_{P1}}{x_{P0}-2x_{P1}+x_{P2}}$

Also, for a known value of $t$ and the according x-value $x_t$ on the bezier curve the x-value of the control point $x_{P1}$ can be calculated as following: $x_{P1} = \frac{x_t - (1-t)^2x_{P0}-t^2x_{P2}}{2(1-t)t}$

However, that's where my brain stops working. Is there a way to combine these formulas? Or do I have to approach this problem with an iterative algorithm where I try different values for $x_{P1}$ to find an approximate?

Example image to illustrate the problem

(Move P1 along the x-axis so that the dashed curve has a maximum x-value at x = 10)


Solution 1:

$p(t) = (1 - t)^2 P_0 + 2 t (1 - t) P_1 + t^2 P_2 $

Taking the derivative with respect to $t$ gives us the tangent vector

$p'(t) = - 2 (1 - t) P_0 + 2 (1 - 2 t) P_1 + 2 t P_2 $

At maximum $x$, the $x$ component of $p'(t)$ is zero. Therefore,

$[p'(t)]_x = - (1 - t) P_{0x} + (1 - 2 t) P_{1x} + t P_{2x} = 0 $

Let $x_0 = P_{0x}, y_0 = P_{0y}, x_2 = P_{2x}, y_2 = P_{2y} $ and $x = P_{1x}, y = P_{1y} $, then the above equation becomes in simpler notation,

$ 0 = (t - 1) x_0 + (1 -2 t) x + t x_2 $

This is a linear equation in $t$, whose solution is

$t = \dfrac{ x_0 - x } { x_0 - 2 x + x_2 } $

Now, we are given that $x_0 =5, x_2 = 7 $, thus

$t = \dfrac{ 5 - x}{12 - 2 x}$

From which,

$(1 - t) = \dfrac{7 - x}{12 - 2x}$

Plugging this into the equation of $[p(t)]_x$ and equating to $10$ results in

$ 10 (12 - 2 x)^2 = 5 ( 7 - x )^2 + 2 x ( 5-x )( 7 - x ) + 7 (5-x)^2 $

This is a cubic polynomial in $x$ and can be readily solved either in closed form or numerically.