How to compensate for vertical displacement when calculating the $x$-velocity of a projectile with a fixed arc height? [closed]

My background

I'm working on a project for a client in the gaming industry. Newtonian physics and vector math is usually my forte, but I'm usually solving problems in directions opposite of what this one requires, and I hit a snag that I'm trying to work through. I'm sure there's a relatively simple answer, but I haven't been able to find one here on SE anywhere that will work with my problem.

There was a similar question asked, but the formulas used by both the answerer and the OP use angular notation for its velocity, not vector notation, and as far as I can tell the answer does not cover the same kind of problem I'm trying to solve.

My problem

I've made a formula that will calculate the individual $$x$$ and $$y$$ velocities needed to launch a projectile from point $$\vec{\mathit{p1}}$$ so that it will reach a height of $$\mathit{h}$$ and land at point $$\vec{\mathit{p2}}$$.

It works when $$\vec{p1}_y$$ and $$\vec{p2}_y$$ are equal...

but starts to miss the farther away $$p2_y$$ gets from $$p1_y$$.

I believe this is because my $$x$$ velocity calculation assumes the projectile will travel the entire distance of the arc to $$\vec{p2}$$, but ends up falling further/shorter when $$\vec{p2}$$ is higher or lower than $$\vec{p1}$$. Therefore, I'm trying to find a way to compensate for the $$y$$ displacement of $$\vec{p2}_y$$ in my $$x$$ velocity calculations

Here's what I have so far: $$points: \vec{p1},\space \vec{p2}$$ $$g = 9.8m/s$$ $$t=\text{Time. Equivalent to f(x)=x.}$$ $$\large{\vec{v_0}=[}f_{\small{vx}}(\small{\frac{v_y}{g}}\large{)},\space v_y\large{]}$$

I first calculate the $$y$$ velocity I need to reach height $$h$$.

$$v_y=\sqrt{2g\space\cdot(h-\vec{p1}_{\large{y}})}$$

With the $$y$$ velocity, I can now use the constant force of gravity to calculate the air time. $$t=\frac{v_y}{g}$$

I then plug the air time into a function that finds the $$x$$ velocity needed to reach $$p2_{\large{x}}$$ before my $$y$$ velocity runs out. $$f_{vx}(t)=\frac{\frac{1}{2}(\vec{p2}_x - \vec{p1}_x)}{t}$$ (If the $$x$$ displacement is not halved in the above formula, the peak of the arc will be directly over $$\vec{p2}$$)

This results in the equation for $$\vec{v_0}$$.

What I've tried so far

I tried finding a way to use a proportion of the untraveled height to adjust the air time that $$f_{vx}()$$ uses. The way I tried was this:

$$c_d=\frac{h-(p2_y-p1_y)}{h}+1$$ (The $$+1$$ is added because the arc is assumed to always have traveled at least $$\frac{1}{2}f_{vx}(v_y)$$, therefore the extra amount over 1 is what is being added on to the $$x$$ velocity)

After I got this correctional value, I tried inserting it into many different spots in the equation, but none seemed to produce the desired result. Am I on the right track?

I feel like I'm close, but missing something important. Any help that can be given would be very appreciated!

• I think it might help you to set $x_0=0$ and $y_0=0$ (without loss of generality since only the distance differences matter). In which case, you know that $v_{0y}$ must equal $\sqrt{2gh}$. They you can use $y_f = \frac{-gx_f^2}{2v_{0x}^2}+\frac{x_f v_{0y}}{v_{0x}}$ to solve for $v_{0x}$ given the final point.
– hft
Commented Oct 6, 2023 at 0:53

1 Answer

The height, $$h$$, determines the $$y$$-component of the initial velocity.

$$y_{\text{max}} = h \;\;\;\;\Rightarrow\;\;\;\; v_y = \sqrt{2g(h-P_{1y})}$$

The end points, $$P_1$$ and $$P_2$$, constrain the trajectory such that $$$$\begin{cases} P_{2x} &= P_{1x} + v_xT \\ P_{2y} &= P_{1y} + v_yT-\frac{1}{2}\,g\,T^2 \\ \end{cases}$$$$

$$T$$ is the time after launch when the particle reaches point $$P_2$$. This is a system with two equations and two unknowns, $$v_x$$ and $$T$$. Solving for $$v_x$$, there are two solutions.

\begin{align} v_x = \sqrt{\frac{g}{2(h-P_{1y})}}\frac{P_{2x}-P_{1x}}{1\pm\sqrt{\frac{h-P_{2y}}{h-P_{1y}}}} \end{align}

The (+) solution has the trajectory reach the maximum height, $$h$$, before reaching point $$P_2$$, and the (-) solution's trajectory reaches the maximum height after passing through $$P_2$$.

• YES! This is it! Thank you so much for your help! Commented Oct 6, 2023 at 2:49