# A Finding firing angle of a projectile with drag.

1. Nov 14, 2016

### SirHall

To find the firing angle to hit a target at a given distance using the initial velocity and gravitational acceleration, we use the formula:
Angle = Firing
XDist = Distance the target is from the gun along the X axis
YDist = Distance the target is from the gun along the Y axis

Angle = radtodeg(arctan((power(Velocity, 2) + sqrt(abs(power(Velocity, 4) - Gravity * (Gravity * power(XDist, 2) + 2 * YDist * power(Velocity, 2))))) / (Gravity * XDist)))

However, I am trying to figure out a way to tell the formula to also account for drag/air friction. My main attempt was to add the distance the projectile loses to the XDist and YDist values, however I think that my scripts aren't exactly correct.
Any help would be greatly appreciated.

#### Attached Files:

• ###### Angle to fire Projectile.png
File size:
1.5 KB
Views:
37
2. Nov 14, 2016

### Simon Bridge

Welcome to PF;
How are you modelling the drag?
Are you trying to do this on a spreadsheet?

Note: you will find it much easier to use LaTeX markup to write equations.
There is a primer here.

3. Nov 14, 2016

### SirHall

Well, my main attempt was to try:
XDist = XDist + (XDist * 'airFriction')
YDist = YDist + (YDist * 'airFriction')
But I realised that this would only work if air friction was linear and if Speed = Speed - friction and not in a rel world evironment where drag is affected by speed aswell.
So, I took a look at the drag/air friction equation and it was actually very similar to what I have.
I use ForceDrag = -Velocity*Constant
In this case 'Constant' = 0.47
Therefore as the projectile moves through the air, speeding up and slowing down, the drag would shorten the distance the projectile travels.
If it's okay, I'm basically looking for a formula that determines how much distance will be lost due to air friction so I can add that distance onto the end of where the target is aiming, to compensate for said air friction.
Thanks for the LaTeX suggestion by the way.

EDIT: Projectiles only 'speed up and slow down' along the Y-Axis, while they simply slow down on the X-Axis.

Last edited: Nov 14, 2016
4. Nov 14, 2016

### Simon Bridge

If I understand you correctly, XDist is the horizontal distance travelled without air resistance?
...so 'airFriction would be between 0 and -1 in that model.

Drag would normally be proportional to the square of the velocity... unless there is something about the circumstances where you can safely take a 1st order approximation?

Because ... ?

You should start off the equations of motion ...
$\sum \vec F = m\vec a \implies -mg\hat\jmath -\sigma v\vec v = m\dot{\vec v}:$ $\vec v(0) = u\hat\imath\cos\theta + u\hat\jmath\sin\theta,$ $\vec r(0)=x_0\hat\imath + y_0\hat\jmath$
... where $\sigma$ is the drag coefficiant for the object in question.
Something like that?

Breaking that into components:

$m\ddot x +\sigma (\dot x^2+\dot y^2)\cos\theta = 0$
$m\ddot y + \sigma(\dot x^2+\dot y^2)\sin\theta +mg = 0$
... giving coupled differential equations.

You have to solve the system to give an expression for the final position, then, for it to work the way you ask, you need to subtract off the solution without drag.
If the idea is to do a computer simulation where the changes in position are very small, then you may get away with a 1st order version of the solution.
However, without knowing what you are trying to do, there is little more I can do to help.

Last edited: Nov 14, 2016
5. Nov 14, 2016

### SirHall

Well thanks for that. Yes a computer simulation is what I'm using this for.
For more detail, I'm trying to figure out a formula that'll allow an AI to fire a projectile at the correct angle to land on a target at any given distance(Assuming it is within range). If the target's y was always equal to the cannon's y this would be simpler, but the AI is programmed to fire at targets at any x and y coordinate(y points downwards). In my specific case, the 'Constant' or C was set to 0.47 as it was simply a distinct number and I chose it just to make sure I didn't confuse it with anything else. Though in Fd = -VC, 'C' would 'act as' the Drag Coefficient. Also yes, XDist is the distance between the cannon and the target but only along the x axis. (Pretty much the difference between their x positions)

Also looked at the drag equation again, and slightly daunted as to how would I find the distance lost in a simple formula.

Will be testing the distances between projectiles with and without the air friction applied.

#### Attached Files:

• ###### daum_equation_1479185531420.png
File size:
3.2 KB
Views:
29
6. Nov 14, 2016

### Simon Bridge

So far it looks like you have target coordinates, and muzzle velocity. You want the program to calculate the angle to hit the target coordinate dead on.
There is no simple formula ... and you should justify any approximations you make (ie. the linear drag model is very bad for the proposed purpose.)

The AI would probably solve the system of DE's numerically - pick your favorite method - or you could hand-solve the equations to find an analytic solution.

Note: I very seldom read pics.

7. Nov 15, 2016

### SirHall

I see, thank you very much sir.

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted