Change the vertex of a parabola while ensuring it still passes through a particular point

408 Views Asked by At

I have a parabola defined by the quadratic equation $y = -(x + 0)(x - endPoint)$, which also passes through a particular point $(a, b)$. I would like to know how to alter the equation so that I can ensure that the vertex of the parabola reaches a particular $height$ while still passing through point $(a, b)$ and while still passing through the $endPoint$ when $y = 0$ (although I don't mind if the other side of the parabola no longer passes through the origin).

For reference, I'm programming a computer game where a projectile moves in a parabolic arc. Point $(a, b)$ is the point from which the projectile is launched, and point $(endPoint, 0)$ is where the projectile lands, which is why those two points must remain immutable. But I need to be able to define how high the parabola is at its apex so that I can ensure the projectile will pass over certain obstacles.

Also, as far as my mathematical skill goes, I've spent the last couple of days digging up my memories of high school quadratics, and that was nearly 20 years ago.

2

There are 2 best solutions below

11
On BEST ANSWER

The general parabola $y = f(x)$ with a given root $p$ (i.e., given $x$-coordinate of the endpoint) has the form $$y = f(x) = - A (x - p) (q - x),$$ where $A$ and $q$ are arbitrary constants. The condition that the parabola passes through $(a, b)$ is that $f(a) = b$, so that $$\boxed{A(a - p)(a - q) = b} .$$ By symmetry the vertex of the parabola has $x$-coordinate $\frac{p + q}{2}$, so the requirement that the parabola has (for $A > 0$) maximum height (i.e., $y$-coordinate) $h$ there is $f\left(\frac{p + q}{2}\right) = h$, or $$\boxed{A (p - q)^2 = -4 h} .$$

Multiplying the equations and canceling $A$ gives $$-4h (a - p) (a - q) = b (p - q)^2 .$$ This is a quadratic equation in $q$, and expanding, collecting like terms in $q$, and applying the quadratic formula gives an expression for $q$ in terms of $a, b, h, p$. Substituting this expression in either of the above boxed equations (the first is easier to use, since it is linear, not quadratic, in $q$) and solving gives an expression for $A$. The result is: $$\boxed{A = \frac{z}{(a - p)^2}, \qquad q = \frac{a z + (p - a) b}{z}, \qquad \textrm{where} \qquad z := b - 2 h + 2 \sqrt{h (h - b)}}.$$

6
On

I will assume that you want the projectile to land at endpoint $(P, 0)$.

A quadratic function that goes through the points $(0,0)$ and $(P,0)$ is of the form $y = mx(x-P)$.

To ensure this also passes through the point $(a, b)$, we would need to plug in $x = a$ and get $y= b$.

This would mean $b = ma(a-P)$ so that $m = b/a(a-p)$.

Therefore, you can use the quadratic function defined by:

$$x \mapsto \frac{bx(x-P)}{a(a-P)}$$

Here is a link to a working example in Desmos: graph

You can alter $a, b, P$ as you wish to see the effects on the graph.


Edit: In keeping with the comment below, here is a modified graph in Desmos.

This is a quadratic function with roots $x=p$ and $x=q$, where the vertex occurs at $(\frac{p+q}{2},H)$ for which each of the three parameters $p, q, H$ is adjustable. The quadratic function is defined by:

$$x \mapsto -\frac{4H}{(p-q)^2}(x-p)(x-q)$$