08-18-2012, 06:55 AM | #1 | |
Spun a twirly fruitcake,
Join Date: Feb 2009
Age: 31
Posts: 3,865
|
Stuck with Selfinflicted Physics Formula
Hi,
I've been working on some formulas in case I would ever need to make game AI; now I'm stuck. First of all, a pathetic paint construction: Now if you say C is an archer standing on a 10 meter high city wall and A is an object it wants to shoot. At what angle X must the archer shoot to hit A? We can assume that the speed of an arrow is 60 m/s and is not affected by drag (i.e. the horizontal speed is constant) and that gravity works at 9,81m/s^2 (only vertical, no curvature of the earth). What I figured out so far is: - Vertical arrow speed = sin ∠X * 60 m/s - Horizontal arrow speed = cos ∠X * 60 m/s - Time it takes to reach its maximum height = sqrt(sin ∠X * 60)/9,81 - Distance the arrow travels from C to D: 2(sqrt(sin ∠X * 60)/9,81) * (cos ∠X * 60) What I haven't figured out: - The formula for the maximum height in meters. - The formula for the horizontal distance travelled from point D to point A. - END: The formula for the angle at which C must shoot. So far I've brainfarted about 5 times on the easiest things. Now I have a headache and the idea that I'm approaching this problem completely wrong and have to start all over. Even if you only give the formula on rough paper, I'll be well satisfied. Thanks in advance, Scintill
__________________
Quote:
|
|
08-18-2012, 09:44 AM | #2 |
End of the road
Join Date: Oct 2006
Location: Canada
Age: 31
Posts: 3,692
|
Re: Stuck with Selfinflicted Physics Formula
Just google projectile motion equations lol. If you haven't gotten it by Monday i'll help you because that's when I get home and won't be on shitty internet :P
|
08-18-2012, 09:56 AM | #3 |
-
Join Date: Jul 2008
Location: Malaysia
Age: 33
Posts: 1,679
|
Re: Stuck with Selfinflicted Physics Formula
To give you a kick in the right direction:
-The horizontal velocities as we know, are constant. That makes it easy for us, distance=velocity*time. The two variables here are time, and angle(which we want to know) -The vertical velocity is the business end of things. Let me rephrase the question: If you shoot an arrow straight upwards at 60*sin(x) m/s, and it decelerates with g=9.81m/s^2, how long does it take before the speed reaches 0? Call this time t_1. You can also find the height travelled at this point -If you were to drop a stationary arrow from that height, acted upon by g=9.81m/s^2, how long before it drops to the level AB(in your diagram)? Call this time t_2 The total time for the arrow to reach from A to C is then t=t_1+t_2 Last edited by LongGone; 08-18-2012 at 10:05 AM.. |
08-18-2012, 10:24 AM | #4 | |
Spun a twirly fruitcake,
Join Date: Feb 2009
Age: 31
Posts: 3,865
|
Re: Stuck with Selfinflicted Physics Formula
The time it takes to reach 0 I already knew, I didn't know how to calculate the height when my trajectory was curved though. I did look up projectile motion formulas and was reacquainted with "s = v0 + .5at^2", so that helped me along
__________________
Quote:
|
|
08-18-2012, 02:50 PM | #5 |
Woof
Join Date: Jan 2006
Location: MA
Posts: 173
|
Re: Stuck with Selfinflicted Physics Formula
Well, I'm on my phone, so let's see how this turns out.
This should help you find the angle. Reference: V0 = initial velocity Vx = velocity in x-direction Vy0 = initial velocity in y-direction Vy = velocity in y-direction g = acceleration due to gravity x = horizontal distance y = vertical distance Q = theta (angle) -- sorry, didn't feel like searching for a theta lol So: Vx = V0*cosQ Vx = x/t V0*cosQ = x/t t = x / (V0*cosQ) Vy0 = V0*sinQ y = Vy0*t + .5g * t^2 y = x * (V0*sinQ) / (V0*cosQ) + .5g * [x / (V0*cosQ)]^2 y = x*tanQ + .5g * x^2 / [V0^2 * (cosQ)^2] y = x*tanQ + .5g * x^2 * (secQ)^2 / V0^2 ****** (secQ)^2 = (tanQ)^2 + 1 y = x*tanQ + .5g * x^2 * [(tanQ)^2 + 1] / V0^2 (.5g * x^2 / V0^2) * (tanQ)^2 + x*tanQ + (.5g * x^2 / V0^2 - y) = 0 ****** A = .5g * x^2 / V0^2 ****** B = x ****** C = .5g * x^2 / V0^2 - y ****** u = tanQ Au^2 + Bu + C = 0 Use quadratic formula to solve for u, then take the arctan of your answer to get one of the angles (assuming there are two). I hope that helps somewhat! I may have messed up since I'm on my phone and it's annoying as fuc to type, but I think that should help get the angle(s) that the archer needs to shoot. Last edited by powerfull; 08-18-2012 at 08:06 PM.. |
08-18-2012, 07:44 PM | #6 |
Fractals!
|
Re: Stuck with Selfinflicted Physics Formula
This sort of thing (as powerfull hinted at) is not too hard to do with the idea of parametric equations. What parametric equations do is express both x and y as functions of a third variable, usually T for time. First, we assume a certain angle of elevation...I arbitrarily choose 60 degrees.
For an angle of 60 degrees up from the horizontal, the trig works out quite neatly: sin 60deg = sqrt(3)/2 and cos 60deg = 1/2. Multiply these by the initial velocity of the arrow (since we're ignoring wind resistance) of 60 m/s to get the parameters of the arrow's motion: The sine represents the vertical portion, so the initial velocity upwards is 30 times the square root of 3. Now taking that plus the fact that the archer is standing 10 meters above ground level, we can use that plus the gravitational constant to find the altitude of the arrow as a function of time t: y = -9.81t^2 + 30sqrt(3)t + 10 Since the horizontal component of the arrow's velocity vector is a constant 30 m/s, we have a simple equation for x: x = 30t It looks like a simple substitution will eliminate the parameter and express y in terms of x, so let's go ahead and do that. *several brain farts later* Screw it, let's use a calculator. My trusty TI-83 Plus tells me that with these parameters, to three significant figures the arrow hits the ground at t=5.48 seconds, the arrow having traveled 164.4 meters horizontally. To figure out the max height of the arrow, we simply need to find where the arrow stops going up and starts going down. To do that, we invoke calculus and take the derivative of y with respect to t, getting this: dy/dt = -19.62t + 30sqrt(3) Now we just need to set the derivative to 0 and solve for t. 0 = -19.62t + 30sqrt(3) 19.62t = 30sqrt(3) t = 30sqrt(3)/19.62 To three sig figs, t ~ 2.65 seconds, which makes sense with the time at which the arrow hits the ground. Now we plug this answer into the original equation to see the maximum height of the arrow, and we get 78.8 meters. ...oh, you wanted to solve for the initial angle to get a horizontal distance of 100 meters. Well, I'm sorry, I hope I at least solved your max-height problem!
__________________
Last edited by igotrhythm; 08-18-2012 at 07:49 PM.. |
08-18-2012, 09:22 PM | #7 | |
Spun a twirly fruitcake,
Join Date: Feb 2009
Age: 31
Posts: 3,865
|
Re: Stuck with Selfinflicted Physics Formula
Yeah, I got that now, but I get confused in my variables when making the formula for the angle
__________________
Quote:
|
|
08-18-2012, 10:18 PM | #8 |
Woof
Join Date: Jan 2006
Location: MA
Posts: 173
|
Re: Stuck with Selfinflicted Physics Formula
How far have you gotten with the angle formula?
Solve for u from my previous post: A = .5g * x^2 / V0^2 B = x C = .5g * x^2 / V0^2 - y u = tanQ Au^2 + Bu + C = 0 u = [-B + sqrt(B^2 - 4AC)] / 2A And / or u = [-B - sqrt(B^2 - 4AC)] / 2A u = tanQ Q = atan(u) Q = atan( [-B + sqrt(B^2 - 4AC)] / 2A ) And / or Q = atan( [-B - sqrt(B^2 - 4AC)] / 2A ) One of those answers will probably be nonreal, but I haven't checked. For the answer that does work, you may have to get the complement of it to get the second angle (again, assuming there are two). And I apologize for not plugging in all the variables for a final equation, I'm still on my phone. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|