Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Projectile motion


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 RAZORUNREAL   Members   -  Reputation: 567

Like
0Likes
Like

Posted 03 October 2006 - 07:08 PM

I'm attempting to find the angle to fire a projectile at such that it lands at a specific point. I have only done (in fact, I havn't even completed) high school level physics and calculus, so please bear with me. Here's what I've done so far: T is the angle fired at (for lack of a theta) Vx is initial horizontal velocity Vy is initial vertical velocity s is the initial speed of the projectile t is time d is horizontal distance to target h is difference in height of target
Vx = cos(T).s
Vy = sin(T).s
d = Vx.t
t = d/Vx
t = d/cos(T)/s
h = Vy.t + 1/2.a.t^2
h = sin(T).d/cos(T) + 1/2.a.(d/cos(T)/s)^2
h = sin(T).d/cos(T) + 1/2.a.d^2/cos(T)^2/s^2
h = tan(T).d + 1/2.a.d^2/cos(T)^2/s^2
So if I could solve that last equation and find T, I'd be pretty much done. But I'm not sure how to do that, and for all I know I'm barking up entirely the wrong tree anyway. Also, if it's not possible to hit the target point, it would be nice to find the angle that comes closest. But it's not essential, I can just set it to 45 degrees and call that good enough. Thanks.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!

Sponsor:

#2 Darkstrike   Members   -  Reputation: 206

Like
0Likes
Like

Posted 03 October 2006 - 08:37 PM

Express the involved polynomials in cos(T) and sin(T) in terms of cos(2T) and sin(2T); you'll get a linear equation in those, which can be easily solved e.g. by converting it further using a "helper" angle.

As to "the angle that comes closest", what exactly is your measure of closeness? The answer depends on this a lot, but in any case, you can calculate the locus of reachable point pretty easily and proceed from there.

#3 daniel_i_l   Members   -  Reputation: 295

Like
0Likes
Like

Posted 03 October 2006 - 09:53 PM

well, you could either sole the trig equation - for that you'd first have to decide on an initial speed (s). or to simplify you could decide on an initial horizontal velocity (Vx) and then use it to get the time (d = Vx*t) and use t to find Vy (h = Vy*t - 0.5g*t^2). with Vy and Vx you can get V and the angle. but if you need a certain V and you only want to get the angle you have to solve the trig equation.

#4 Necator   Members   -  Reputation: 239

Like
0Likes
Like

Posted 04 October 2006 - 04:51 AM

as Darkstrike wrote, you need to transform the sin & cos terms using
sin(2x)=2*sin(x)*cos(x) and
cos(x/2)^2=(1+cos(x))/2

When I calculated it, I used a different direction of the acceleration, but it's just to insert (-a) instead of a.

s^2*h*cos(T)^2 = s^2*sin(T)*cos(T)*d - a*d^2/2

(1+cos(2T))*h/2 = sin(2T)*d/2 - a*d^2/(2*s^2)

(a*d^2+h*s^2)/s^2 + h*cos(2T) = d*sin(2T)

Set (a*d^2+h*s^2)/s^2 = C.

h*cos(2T) + C = d*sin(2T)

cos(2T)*h/d + C/d = sin(2T)

For the rest I made a very nice Paintbrush picture ^^

description of your image

T = (asin(C/sqrt(d^2+h^2)) + atan(h/d))/2

I could have forgot some special case for asin or atan, but the basics should be correct. Probably a couple of typos too... =)

#5 NotAYakk   Members   -  Reputation: 876

Like
0Likes
Like

Posted 04 October 2006 - 06:35 AM

Sadly, what you described neglects air resistance/wind -- which are rather important, if you want realistic projectile motion.

There is an alternative way to solve such problems. It isn't always best.

Basically, you search for the right firing solution, instead of calculating it.

Start out with sampling the "space" of possible firing options either randomly, or with some best guesses.

Now use those samples to figure out a better set of samples. Repeat until you are close enough.

If you have a simple enough problem, you can often get solutions that 'braket' your target -- one shot is to the left, the other to the right. In that case, a simple binary or dictionary search often rapidly produces an accurate solution.

..

In your particular example, let's first solve for t in terms of h and Vy.

a/2 t^2 + Vy t - h = 0

t = -Vy +/- sqrt(Vy^2 + 2 a h)
----------------------------
a

There are two solutions to the above. So for a given Vy, we have t0 and t1.

Next, see how far away horizontally the shot is at t0 and t1:

d = Vx * t
d0 = t0 Vx
d1 = t1 Vx

That is pretty easy!

Now, we start out by testing a bunch of different random firing solutions. We stop after testing a large number, or after we have 'bracketed' the target (got one to land on the far side, and one to land on the near side, of the target).

Once we have 'bracketed' the target, we simply engage in a binary search through the firing space between the two options.

If we haven't bracketed the target, it is possible the target cannot be hit. We take the closest shot to the target in t0, search the solutions near it, and give up if we stop getting closer. We then do the same with t1 solutions.

All of the above does is solve the problem in a way that doesn't rely on the equations described being 'easy to solve' -- if you added tweaks to the equations (wind resistance), the above solution would be more robust (it wouldn't be guaranteed to work!) compared to the analytical solution.


#6 RAZORUNREAL   Members   -  Reputation: 567

Like
0Likes
Like

Posted 04 October 2006 - 03:53 PM

Thanks for your help guys! Especially Necator. It works perfectly.

Quote:
Original post by NotAYakk
Sadly, what you described neglects air resistance/wind -- which are rather important, if you want realistic projectile motion.


I'm not worried about air resistance right now, but that technique does look useful.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS