# Finding firing angle of a projectile with drag.

• SirHall
In summary, the AI is trying to find a firing angle that will hit the target at a given distance using the initial velocity and gravitational acceleration. However, they are struggling to model air friction and drag and are looking for a way to include it in the equation.
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.

#### Attachments

• Angle to fire Projectile.png
1.6 KB · Views: 641
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.

Simon Bridge said:
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.
Well, my main attempt was to try:
XDist = XDist + (XDist * 'airFriction')
YDist = YDist + (YDist * 'airFriction')
But I realized 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:
SirHall said:
Well, my main attempt was to try:
XDist = XDist + (XDist * 'airFriction')
YDist = YDist + (YDist * 'airFriction')
But I realized that this would only work if air friction was linear and if Speed = Speed - friction and not in a real world evironment where drag is affected by speed aswell.
If I understand you correctly, XDist is the horizontal distance traveled without air resistance?
...so 'airFriction would be between 0 and -1 in that model.

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
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?

In this case 'Constant' = 0.47
Because ... ?

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.

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:
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.

#### Attachments

• daum_equation_1479185531420.png
2.6 KB · Views: 622
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.

Simon Bridge said:
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.
I see, thank you very much sir.

## 1. What is the firing angle of a projectile with drag?

The firing angle of a projectile with drag refers to the initial angle at which a projectile is launched in order to achieve a desired trajectory, taking into account the effects of air resistance or drag.

## 2. How is the firing angle of a projectile with drag calculated?

The firing angle of a projectile with drag can be calculated using mathematical equations that consider the projectile's initial velocity, mass, and the drag coefficient of the medium it is traveling through. It can also be determined through experimentation and data analysis.

## 3. What factors affect the firing angle of a projectile with drag?

The firing angle of a projectile with drag is affected by several factors, including the initial velocity of the projectile, the mass of the projectile, the angle of launch, the drag coefficient of the medium, and the distance the projectile needs to travel.

## 4. Why is it important to find the firing angle of a projectile with drag?

Finding the firing angle of a projectile with drag is important in order to accurately predict the trajectory of the projectile and ensure it reaches its intended target. It is also important for optimizing the efficiency and accuracy of projectile-based systems, such as weapons or sports equipment.

## 5. Can the firing angle of a projectile with drag be changed?

Yes, the firing angle of a projectile with drag can be changed by adjusting the initial velocity, mass, or launch angle of the projectile. It can also be affected by external factors such as wind or changes in the drag coefficient of the medium.

• Mechanics
Replies
4
Views
1K
• Mechanics
Replies
3
Views
4K
• Mechanics
Replies
2
Views
1K
• Mechanics
Replies
2
Views
3K
• Mechanics
Replies
5
Views
6K
• Mechanics
Replies
2
Views
1K
• Mechanics
Replies
8
Views
1K
• Introductory Physics Homework Help
Replies
1
Views
855
• Mechanics
Replies
29
Views
4K
• Programming and Computer Science
Replies
7
Views
1K