Trajectory With Air Resistance

195 Views Asked by At

For a video game, I am trying to calculate the angle needed for a projectile to hit coordinates x,y (both non-zero) with air resistance, i used equations from this site, and derived a function of y relative to x (height at x):

$$y=q \frac{x}p+r \ln⁡(1-\frac{x}p)$$ where $$p=\frac{v_0 v_t \cos⁡θ}g$$ $$q=\frac{v_t}g (v_0 \sin⁡θ+v_t )$$ $$r=\frac{v_t^2}g$$ $v_0$ is the launch velocity, $v_t$ is the terminal velocity, $g≈9.81$ is the gravity force, and $\theta$ is the launch angle

Of course, the equation can be written as $$y=\frac{v_0 \sin⁡θ+v_t }{v_0 \cos⁡θ } x+\frac{v_t^2}g \ln⁡(1-\frac{xg}{v_0 v_t \cos⁡θ })$$ or $$\tan⁡ (θ)x +\frac{v_t}{v_0 \cos⁡θ } x+\frac{v_t^2}g \ln⁡(1-\frac{xg}{v_0 v_t \cos⁡θ })-y=0$$

so, given x and y, I need to solve it for ⁡θ, I couldn't isolate ⁡θ to get an equation of the form $⁡θ=\arctan(...)$ or similar, is that even possible?

and if it's not possible, I can use searching method, which recursively searches for an approximate solution between 2 values of $\theta$, but to do that i have to find 2 values to search between: $\theta_{near}$ should get the projectile nearer than the target, and $\theta_{far}$ should get the projectile further, so this method needs searching for 2 values first, but it's not guaranteed to find a value for $\theta_{far}$ even if there was a solution to the equation.

Is there a better way to deal with this, maybe differential equations or something, i just don't know where to go from here.

Edit: due to change in requirements, I want to solve this to $v_0$ as well, so the game designer can experience aiming by cannon strength instead of aiming by angle, maybe this is less complicated since $v_0$ is not in sin or tan... but it's still inside the ln, so solving it for $\theta$ will give me an idea how to solve it for $v_0$.