Approaching a Trajectory Problem

139 Views Asked by At

I am trying to design a railgun simulation. The idea is that the user can supply a starting point and velocity vector for a launcher and for a target, and the launcher will find the angle to launch the projectile at. I previously created a program that would model a roman candle's projectile motion with wind resistance by using a Runge-Kutta ODE, in 2D. Now I pretty much want to work backwards from that. I however have a few questions about how to approach this problem:

  1. Is it possible to work backwards using this ODE as a model? I am under the assumption that the answer is no, and I'll have to brute-force it by sweeping through different angles (perhaps solving the trajectory without wind resistance and using that angle as a starting point?)
  2. In terms of computation time, using multi-threading, solving for theta in a 2D system shouldn't be too bad. However, assuming the only way to solve the problem is sweeping through values, this seems to get complicated when trying to compute a 3D system. These are the equations I found online:

x = cos(theta) * cos(phi)

y = sin(theta) * cos(phi)

z = sin(phi)

Now there's two sets of values to sweep through (as if a theta is found, the values of x and y will change when sweeping through phi values). So this is especially where a better method for finding the angles would be beneficial.

If it helps at all, this was the general form of Runge-Kutta used in the previous program: $$q_{1x}= f_{x}(t_{k}, v_{xak}, v_{y})$$ $$q_{1y}= f_{y}(t_{k}, v_{xak}, v_{y})$$ $$q_{2x}= f_{x}(t_{k} + \frac {\Delta t}{2} , v_{xak} + \frac {\Delta tq_{1x}}{2} , v_{y} + \frac {\Delta tq_{1y}}{2})$$ $$q_{2y}= f_{x}(t_{k} + \frac {\Delta t}{2} , v_{xak} + \frac {\Delta tq_{1x}}{2} , v_{y} + \frac {\Delta tq_{1y}}{2})$$ $$q_{3x}= f_{x}(t_{k} + \frac {\Delta t}{2} , v_{xak} + \frac {\Delta tq_{2x}}{2} , v_{y} + \frac {\Delta tq_{2y}}{2})$$ $$q_{3y}= f_{x}(t_{k} + \frac {\Delta t}{2} , v_{xak} + \frac {\Delta tq_{2x}}{2} , v_{y} + \frac {\Delta tq_{2y}}{2})$$ $$q_{4x}= f_{x}(t_{k} + \Delta t , v_{xak} + \Delta tq_{3x}, v_{y} + \Delta tq_{3y})$$ $$q_{4y}= f_{y}(t_{k} + \Delta t , v_{xak} + \Delta tq_{3x}, v_{y} + \Delta tq_{3y})$$ $$v_{x(k+1)}= v_{xk} + \frac {\Delta t}{6}(q_{1x} + 2q_{2x} + 2q_{3x} + q_{4x})$$ $$v_{y(k+1)}= v_{yk} + \frac {\Delta t}{6}(q_{1y} + 2q_{2y} + 2q_{3y} + q_{4y})$$

Where: $$f_{x}(t, v_{xa}, v_{y})=\frac{dv_{x}}{dt} = -\frac{F_{D}v_{xa}}{mv}$$

And: $$f_{y}(t, v_{xa}, v_{y})=\frac{dv_{y}}{dt} = -g-\frac{F_{D}v_{y}}{mv}$$

Any help would be appreciated!

Thanks, Nic