Finding necesary Muzzle Velocity?

  • Thread starter Thread starter sciwizeh
  • Start date Start date
  • Tags Tags
    Velocity
Click For Summary

Homework Help Overview

The discussion revolves around deriving the necessary muzzle velocities for two cannons positioned in 2D space, with a focus on determining the x and y components of velocity based on a randomly generated angle. The original poster seeks to establish these velocities without time dependency, which presents challenges in the context of projectile motion.

Discussion Character

  • Exploratory, Assumption checking, Problem interpretation

Approaches and Questions Raised

  • Participants discuss the need for input parameters to calculate the required velocities, questioning how to derive these values without time dependency. The original poster mentions having the height and distance between the cannons, while others suggest that there are multiple velocity pairs that could achieve the same target. Some participants introduce formulas related to projectile motion and inquire about the implications of different heights of the cannons.

Discussion Status

The conversation is ongoing, with participants exploring various formulas and approaches to derive the initial velocities needed for the cannons. Some have provided mathematical expressions relevant to the problem, while others express confusion regarding the implementation of these formulas in code, particularly when encountering issues such as NaN results. There is no explicit consensus yet on a definitive method or solution.

Contextual Notes

Participants note the importance of ensuring that the parameters used in calculations yield valid results, particularly regarding the conditions under which certain angles may not produce a feasible solution. The original poster's requirement for a non-time-dependent approach is also a significant constraint in the discussion.

sciwizeh
Messages
25
Reaction score
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
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...
 
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.
 
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.
 
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).
 
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.
 
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?
 
not quite,
this sums it up (hopefully my poor drawing abilities get the point across):
physicsquestion.png
 
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?
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
11
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 20 ·
Replies
20
Views
3K
Replies
2
Views
938