Easy Question: Formula for Launch Angle? Projectile Motion.by jllorens Tags: angle, formula, launch, motion, projectile 

#1
Jan1812, 11:59 PM

P: 8

Edit: I solved my problem for launch angle. So now I have another question.
I am writing a script for a cannon in a video game that will aim at XYZ coordinates by determining the angle and bearing needed to launch the projectile to hit the target. I wish to add a targetleading formula so that it can lead targets moving in a straight line with constant velocity. The problem is that the time to impact, "t," must be factored into determining the coordinates to aim at in order to lead the target, but in order to determine the time to impact, the coordinates must be known. So, given the current XYZ of the target, the initial XYZ of the projectile, the initial velocity of the projectile, and the velocity of the target, is there any way to solve for the XYZ of where the target will be in an unknown timespan "t" (the flight time of the projectile)? 



#2
Jan1912, 06:12 AM

Sci Advisor
PF Gold
P: 11,341

You need to be solving a pair of simultaneous equations. Alternatively, you could google trajectories/ballistics/artillery and there is bound to be a formula in there somewhere. (I chucked out my School Maths note book nearly fifty years ago but is was in there somewhere.)




#3
Jan1912, 08:51 AM

P: 3

The equation of trajectory might be helpful in finding out the desired result.Although,it may lead to complex mathematics.




#4
Jan1912, 09:10 AM

Sci Advisor
PF Gold
P: 11,341

Easy Question: Formula for Launch Angle? Projectile Motion.
It depends on what you call complex. If you are making a video game then you are, presumably, using a processor and a programming language. All the languages can evaluate simple mathematical expressions. The shape of the trajectory need not be too accurate as long as the ends are in the right place.




#5
Jan1912, 09:45 AM

P: 8

It seems to me that there are too many unknowns.
I have the trajectory equation down, I can get the right angle to hit any target at any elevation (assuming it is within range) with a mortar shot (high angle shot as opposed to low angle). But the target leading seems to require a "guess and check" method. The problem with such a method is that it takes time for a computer to run, time that during which, the target will move thus altering the "future position" at a time T seconds from the moment of calculation, so this method basically forces itself to give a wrong answer simply because of the time it takes to perform. I don't know if it is possible, unless you could somehow get an equation for T (time of flight) that does not require X and Y to be known (2d projectile motion). Plus it just logically feels like an impossible thing to answer. It is like asking someone with a giant supercomputer that could compute the probabilities at a subatomic level to predict the future: "What happens at a precise moment in time in the future?" "Well when is this precise moment in time?" "I don't know." 



#6
Jan1912, 11:09 AM

Sci Advisor
PF Gold
P: 11,341

I see your problem. It looks like you would need some successive approximation loop. Not too hard, though, because they used to use 'predictors' on AKAK guns in the WW2 and they would have been really sluggish, analogue things. The time taken would depend upon the required accuracy.
BTW, you say you can do the 'mortar' trajectory and not the 'field gun' trajectory. They both just involve the two possible roots of the quadratic equation so either should be just as easy. (no?) 



#7
Jan1912, 11:39 AM

Sci Advisor
PF Gold
P: 11,341

Some opinions are in here.




#8
Feb2112, 04:20 PM

P: 2

I was just working out the details of this same exact problem for an AI mortar for a game. Here is what I've come up with. I am not using standard spherical coordinates so I have tried to designate my angles using different designations than usual.
α is the change in angle from the position of the target and where the target will be when the projectile hits the ground. t = 2v/g cos(ψ) where ψ is the angle from the zaxis (I assume z is pointing upwards), and v is the muzzle velocity. The AI engine is going to be aware of the NPC's position at any given time. so at t=t₀ the NPC is located at (x₀, y₀, z₀). At t = 2v/g cos(ψ) the NPC is located at (x₁, y₁, z₁). Since the target is moving with velocity u along some (hopefully predictable) path. we can describe the path using some function. For my purposes these are lines but you may do something different so lets just say. r(t) is some vector function that returns a position at a given time. We can then use the distance formula to calculate the distances between the current position and the landing position. d₁ = distance between current position of target d₂ = distance between me and target after the projectile flies These give me a triangle where the only missing side is the side connecting these two points to eachother. For me this is easy to handle using r(t) = vt but in general, you can use the average value formula to connect these. Thus your AI won't be dead perfect at shooting NPC's but it will be darn close. We will call that other side d₂₁ and across from it was our earlier presented angle α. cos(α) = ((d₁)² + (d₂)²  (d₂₁)²)/(2√(d₁d₂)) Which as you imagine came from the law of cosines, but more importantly, this one is not too computationally expensive depending on what your r(t) function looks like. In my code these distances had to be calculated for something else anyway so the algorithm made sense and it is not some recursive type function that reduces error with each iteration like you'd been suggested to use previously. 



#9
Feb2112, 04:26 PM

P: 2

That time is basically constant in particular you can choose for your AI to launch at ψ = π/4 for all your calculations to simplify things substantially. 


Register to reply 
Related Discussions  
Projectile Motion: Finding the correct angle for a launch  Introductory Physics Homework  6  
Projectile motion problem involving finding launch angle  Introductory Physics Homework  5  
Projectile motion initial velocity and launch angle  Introductory Physics Homework  17  
Very vague question about projectile launch angle  Introductory Physics Homework  2  
Deriving a Launch Angle Equation  Projectile Motion  Please Help  Introductory Physics Homework  5 