Finding necesary Muzzle Velocity?

  • Thread starter sciwizeh
  • Start date
  • Tags
    Velocity
In summary, the conversation discusses the problem of finding the x and y velocities for two cannons in a 2D space, given a constant angle and no time dependency. The conversation also covers the inputs needed for the simulation and the use of kinematic equations. The formula for finding the range of the projectile is mentioned, as well as formulas for finding the angle and velocity when the firing cannon is higher or lower than the other one. The conversation ends with a discussion about implementing these formulas in Java and some issues that arise.
  • #1
sciwizeh
25
0
First off, this isn't Homework so there is no question per se. I'm having deriving something that probably was in my Physics I/II course, but I forgot.

Here's my problem... I have two cannons (points) in 2D space, I'm not using vectors, just separate scalars for both the x and y coordinates I have a constant angle (generated randomly) and what i want to try to find are the x and y velocities. I need no time dependency in the formulas.

so far i think i have the y velocity but I'm not sure, and I'm at a loss to get the x velocity:

from the formula: v^2=V0^2+2g(r-r0), I was able to get v0=sqrt(2g(r-r0)-v).

but I don't want any dependence on v or time, so I'm slightly stuck.

(I'm trying to write AI for a 2D cannon computer game)
 
Physics news on Phys.org
  • #2
To find two numbers, namely the x and y velocities, you will need some input parameters. You should know that, without input numbers, you cannot expect an algorithm to produce output numbers. So you are looking for the x and y velocities knowing what quantities?

In a simulation, such as the one you are suggesting, one assumes that the initial velocity components are known and then one let's the trajectory evolve from these using the kinematic equations. Or if you want to put a cannon shell over a castle wall, then your input parameters are the distance of the cannon from the wall and the height of the wall.

What are yours? Also, how can you have an animation without time dependence? I am curious...
 
  • #3
I assume that you want 1 cannon to shoot at the other cannon. There are actually an infinite number of (x,y) velocity pairs. If you have a very small x velocity, then you would need a very large y velocity to reach the cannon and vice versa.
 
  • #4
Well, as for inputs there will be the difference in x coordinates and the difference in y, I will have it generate a random angle for the cannon to fire at (between 0-90 of course)
and all I want to find is the required velocities for hitting the target. there will be terrain, but I already have it destroyable, so getting around it isn't the problem.

the animation is dependent on time, I'm using very simplistic integration that only knows the elapsed time from the last step:
ballVY += GRAV*dt;
ballX += ballVX*dt;
ballY += ballVY*dt;

but i want to know the required initial velocity before the animation begins, so I can start it as such.
 
  • #5
If the projectile lands at the same height from which it was launched, the range (horizontal distance) is given by

[tex]R=\frac{v_{0}^{2}sin(2\theta)}{g}[/tex]

Note that you can get the same range for 45o-θ (howitzer trajectory) as for 45o+θ (mortar trajectory).
 
  • #6
good to know, solving for v0 would be exactly what i need, but they are likely to be at different heights, so what if they have different heights? that is what is really stumping me. i do have the height of each.
 
  • #7
If you have the maximum height (h) and the range (R), then a useful formula is

[tex]tan\theta=\frac{4h}{R}[/tex]

This is independent of the initial speed. Is that what you were after?
 
  • #8
not quite,
this sums it up (hopefully my poor drawing abilities get the point across):
physicsquestion.png
 
  • #9
I understand. It's getting late where I am. I will come up with an answer in a few hours.
 
  • #10
When the firing cannon is higher than the other one, the angle is given by

[tex]tan\theta=\frac{v^{2}\pm \sqrt{v^{4}-g(gR^{2}-2v^{2}h)}}{gR}[/tex]

Here

v = muzzle speed of cannonball
R = horizontal distance between cannons
h = vertical distance between cannons

The speed and both distances are positive numbers.

When the firing cannon is lower than the other one, use the same expression but change the term between parentheses under the radical from (gR2-2v2h) to (gR2+2v2h).

There are two things your code should test for before applying this

1. The term under the square root must be positive. If negative there is no angle for the given parameters.
2. If test 1 is passed, check for negative angles. Assuming that the cannons cannot fire below the horizon, negative angles should be discarded.
 
  • #11
I'm having some trouble implementing this, i keep getting NaN (aka, i). I understand that for some angles there is no velocity that will suffice, but when i don't get NaN the velocity is not enough to reach the other cannon.
this is in java, but it should be easy enough to understand for anyone:
Code:
                angle = Math.random()*(Math.PI/2-Math.PI/90);
                /**
                 * Used for AI formula
                 *          _______________________
                 *         / gR^2(tan(theta)^2+1)
                 *  V =   /  ---------------------
                 *      \/    3(Rtan(theta)(+-)h)
                 */
                
                double R = Math.abs(CANNON_1_X-CANNON_2_X);
                double g = GRAV;
                double tan = Math.tan(angle);
                double h = Math.abs(cannon2PosY-cannon1PosY);
                double RSqu = R*R;
                double tanSqu = tan*tan;
                double top = (g*RSqu*(tanSqu+1));
                double bottom;
                if(cannon1PosY<=cannon2PosY){
                    bottom = (3*(R*tan+h));
                } else {
                    bottom = (3*(R*tan-h));
                }
                double frac = top/bottom;
                double neededPow = Math.sqrt(frac);
NOTE: the coordinate system is 0 at the top increasing downward

neededPow should be the velocity, later i do a check for NaN, but this isn't giving correct results, do you guys see anything wrong with it?
 

1. What is Muzzle Velocity?

Muzzle Velocity is the speed at which a projectile (such as a bullet or missile) leaves the barrel of a firearm or other weapon. It is typically measured in feet per second (fps) or meters per second (m/s).

2. Why is Muzzle Velocity important?

Muzzle Velocity is important because it directly affects the accuracy, range, and impact of a projectile. The higher the Muzzle Velocity, the farther and faster the projectile will travel, and the more force it will have upon impact.

3. How do you calculate Muzzle Velocity?

Muzzle Velocity can be calculated by using the formula MV = √(2E/m), where MV is the Muzzle Velocity, E is the energy of the projectile, and m is the mass of the projectile in kilograms. This formula takes into account factors such as the weight of the projectile and the amount of energy it has when it leaves the barrel.

4. What factors can affect Muzzle Velocity?

Muzzle Velocity can be affected by a number of factors, including the type and size of the firearm, the type and weight of the projectile, the type and amount of gunpowder or propellant used, and environmental factors such as altitude and wind.

5. How can Muzzle Velocity be measured?

Muzzle Velocity can be measured using specialized equipment such as a chronograph, which uses sensors to track the speed of the projectile as it passes through a designated area. It can also be estimated by analyzing the trajectory and impact of the projectile, but this method may not be as accurate.

Similar threads

  • Introductory Physics Homework Help
Replies
5
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
770
  • Introductory Physics Homework Help
Replies
4
Views
355
  • Introductory Physics Homework Help
Replies
5
Views
2K
  • Introductory Physics Homework Help
Replies
2
Views
819
  • Introductory Physics Homework Help
Replies
11
Views
958
  • Introductory Physics Homework Help
Replies
6
Views
158
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Introductory Physics Homework Help
Replies
7
Views
216
Back
Top