# Projectile Motion, finding required theta of launch

Tags:
1. Mar 16, 2016

### Zacattackz

1. The problem statement, all variables and given/known data
The objective is to code a working solver, but my question is specifically with the physics aspect. I am to find the θ value necessary to launch a projectile and hit a target. My problem is distinguishing between an overshoot and an undershoot. For example:

Both of these launches have minimum points (the dots), that represent their closest point to the target (red with cross). Both of the minpoints fall in the same quadrant relative to the target (quadrant 3), but the blue needs to decrease the launch angle, while green needs to increase. How do I tell the difference between these and so tell my code whether to increase or decrease its guess? If the minpoint lands in any other quadrant I decrease or increase θ accordingly (decrease for quad 1,2 ; increase for quad 4)

2. Relevant equations
x,y,θ, velocity are known at all points on the line. As well as their derivatives.
To find the minpoints. ν⋅d = 0 is used where:
ν=velocity vector= xdot*i+ydot*j
d=vector from projectile to target=(T_x-x)*i+(T_y-y)*j
Target location = (T_x,T_y)

The code will solve for when v⋅d is equal to zero. Here is a picture illustrating that instance:

edit: I realize the velocity vector should fall inside of the blue, my mistake
3. The attempt at a solution
Here is an example of what my code does.Each image shows a successive guess angle and its corresponding path. The red circle is the target, while circles on the path indicate where a minimum distance has been found.

http://imgur.com/a/YPlv9

The first guess is an undershoot, while the second is a "high" undershoot. Causing the final guess to change the theta angle in the wrong direction. I need a way to detect when the guess is a "high" undershoot.

Last edited: Mar 16, 2016
2. Mar 16, 2016

### PAllen

Just to be clear, you are not restricting to parabolic trajectory, you want to allow drag, possibly non-linear drag? With parabolic trajectory, the problem is trivial. However, given what you say you know about the trajectory, any standard 'shooting method' for two point value boundary value problems should suffice. Are you familiar with these?

For these, you would 'integrate' to the x coordinate of the target, and then adjust based on whether you hit above or below the target y. These methods would converge very efficiently for your problem.

Last edited: Mar 16, 2016
3. Mar 16, 2016

### Zacattackz

Yes, there is drag. I didn't post the 4 ODEs used to solve for the projectile's path, but can if that would help.

Integrating to the x coordinate would work (with exceptions for when the projectile hits the ground). But isn't as efficient because of the exceptions (I think). Integrating a high shot for its trajectory until termination (y=0) would be a longer integration than to any minpoint. I believe it would also run into the same problem. A high shot could fall under the target, while a low shot could as well.

4. Mar 16, 2016

### PAllen

Take the ground out of your problem. It isn't necessary. Then, you have no exceptions. You do have to integrate further, but convergence should be very rapid with standard methods (you should need e.g. 6 tries for very good precision).

5. Mar 16, 2016

### Zacattackz

That method still runs into the same problem. With a high shot I can still land underneath the target in the same way that a low shot can. Here's a pic: (starting velocities aren't constant, blue path should be higher, but you get the idea)

For a given starting velocity there should usually be 2 different paths to the target. A "direct" path, and a "high" path that runs into excess air resistance before dropping onto the target. It doesn't matter which path I use, but I do need to realize which path was attempted and was hoping there was a way to determine this before a solution is found.

6. Mar 16, 2016

### PAllen

You don't need to know which path case you are. You just need to find (possibly numerically) the derivative of y intercept with angle for a starting guess. That tells you which way to go for that starting path.

7. Mar 16, 2016

### Zacattackz

Could you explain that better? I should find my velocity vector when the height is the same as the target height?

8. Mar 16, 2016

### PAllen

I would hope you can derive something from your diff eqs. However, if you can't, you just integrate to y intercept for two very close values of theta. Compute a numeric derivative of y intercept with theta, and this tells you which way to go.

I would suggest one starting point:

https://www.amazon.com/Numerical-Re...7154&sr=8-1&keywords=numerical+recipes+in+c++

which has nice chapter on solving such problems. Forget using their code if you want to do your own, but they explain the methodology quite well (IMO). Two Point Boundary Value Problems is the relevant chapter.

Last edited by a moderator: May 7, 2017
9. Mar 16, 2016

### Zacattackz

The problem requires using the given ODE solver to create the projectile's path. It also requires use of the bisection method to determine the next guess point (I think this was done to make the project easier, not having to figure out a root solver). Anyways, because the bisection method has no knowledge of previous guesses other than if they were high/low, I don't think it would be usable with the derivative of the y intercept.

That restriction also rules out the shooting method and others mentioned in the book. As my actual root finder is pre determined.

I'm guessing, once we submit our code, the target location used to grade it will be close to the launch point. Which will cause only extremely high theta values to return the "high" undershoot, and those likely won't be "guessed" by the bisection method.

10. Mar 17, 2016

### PAllen

That clears up several things. However, even with bisection you can use the method I described for a numeric derivative estimate to decide which way to search. Start taking steps in the direction indicated by the derivative until you get to the other side of the target. Then bisect, keeping two thetas which land above and below the target. Binary intersections is fine and robust if slow.

11. Mar 17, 2016

### Zacattackz

I could if I had good boundaries. But all I'm given is the target will land in the first quadrant. Necessitating boundaries of θ = 0 and θ = 2π. What could occur is landing just under the target, adjusting to a higher theta, and having a "high" overshoot and raising theta again. I'm probably overthinking the problem and the target locations used to grade the code will be easy to solve for.

12. Mar 17, 2016

### PAllen

I think you are overcomplicating. Given a target location, in the first quadrant, theta must be between 0 and pi/2 (or -pi/2 to pi/2 if the start can be higher than the target). Drag isn't going to make a projectile go backwards or float upwards. Then, start with guess of straight line between the start and the target. This should necessarily be low. Then increase angle in steps of any decent size till you land on other side of target. Then bisect.

13. Mar 17, 2016

### Zacattackz

Yes, my mistake, I meant π/2.

While it would be great to increase theta in routine intervals till a sign change occurs. The bisection restriction necessitates cutting almost in half on the first jump. And the project was originally described as "code your own bisection method but I should be able to replace it with my own version and might do just that" Thanks for the help!