Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2005-10-03 11:15:10

raffy
Member
Registered: 2005-10-03
Posts: 3

needed: formula for curved trajectory to hit specific target

Hi,
I'm building a game based on tank wars.
The enemy tank ('computer') knows where the player's tank is, and the distance and the direction it has to fire to hit the player's tank in a straight line.

I want the 'computer's' tank to be able to fire at the player's tank and hit it, but for the missile to move on a curved path - not a straight line.

Can anyone provide me with a foolproof  and ideally simple formula for this?

I figure that because I know the average velocity surely I can find a formula that creates a curved path based on the given velocity so that the curved path and straight path intersect at the target at the same time, but it appears to be beyond me.

For anyone interested, I'm building it in Flash.
Thanks for your help and for saving my brain!


Raffy

Offline

#2 2005-10-03 12:22:23

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,529

Re: needed: formula for curved trajectory to hit specific target

Hi Raffy, I do some Flash, but I am not very good.

The general formula for trajectory is:

x = vt cos θ
y = vt sin θ - ½ g t²

v is the velocity (in metres per second to agree with the other values below). Now in reality the velocity will slow down due to drag, but that makes it really hard, so let us just say it is the same all the way through!

θ is the angle you launch it at

g is the downwards accelaration caused by gravity = 9.81 m/s²

t is time in seconds

So, you can plot it's path by keeping track of when it was fired.

Let's fire it at 20 m/s velocity pointing 70° up, and it is now 2 seconds after firing, then the missile will be at:

x = vt cos θ = 20 x 2 x cos 70 = 13.7m along
y = vt sin θ - ½ g t² = 20 x 2 x sin 70 - ½ x 9.81 x 2² = 37.6 - 19.6 = 18.0m up

It should look really neat when animated. Try plugging in these values and with a bit of scaling you should be able to make a shape follow a nice trajectory.

But that is only a start, so let us know how you get on.


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#3 2005-10-04 01:00:33

raffy
Member
Registered: 2005-10-03
Posts: 3

Re: needed: formula for curved trajectory to hit specific target

Thanks,

This is a huge help. What I really need to know is...

If I have a fixed point that I want my projectile to hit, and I can set it's angle when it launches and I know the co-ordinates of the target, what is the equation to ensure the projectile hits it.
There is no wind resistence or acceleration, just a continual x velocity and a y velocity that curves.

If I can hit it in a straight line easily enough, why can't I distort the straight line path so that it curves higher than the target initially and then curves back down to hit it?

Offline

#4 2005-10-04 03:57:38

Owlbert
Guest

Re: needed: formula for curved trajectory to hit specific target

Good morning,

http://sigchi.org/chi97/proceedings/paper/ja.htm

might be useful.

Enjoy,

-- Owlbert

#5 2005-10-04 09:46:15

John E. Franklin
Member
Registered: 2005-08-29
Posts: 3,552

Re: needed: formula for curved trajectory to hit specific target

Also, you might try posing this question on ILovePhysics.com's forum.
They will certainly help you out.  I have been enjoying that forum ever since Chris
introduced it to us here.


igloo myrtilles fourmis

Offline

#6 2005-10-04 10:40:42

MathsIsFun
Administrator
Registered: 2005-01-21
Posts: 7,529

Re: needed: formula for curved trajectory to hit specific target

Thanks for the links, Owlbert and John.

I had a friend who was in the Norwegian Army. He was a laser-rangefinder. His job was to move to a forward position where he could see an enemy tank as well as his own artillery. If he could get an accurate fix on both, then his artillery could lob a shell onto a tank that was way out of site for them!

Using:

x = vt cos θ
y = vt sin θ - ½ g t²

You can solve for x and y.

So, if you know that the enemy position is 300m away and 20m higher you would have:

300 = vt cos θ
20 = vt sin θ - ½ g t²

Now, you have 2 equations and 3 unknowns (v,t and θ), so you need one less unknown. Why not choose one of the values?

That's right, you can choose, because there will be a "family" of curves that will hit the target.

For example, if you choose a high angle and just the right speed, then you can hit the target, exactly as you could with a low angle.

So, pick one of the variables, say angle, and give it a value (though not all values will have a solution), let's say 60.

cos 60 = 0.5
sin 60 = 0.866

So, now we have:

300 = vt (0.5)
20 = vt (0.866) - ½ g t²

the first equation gives us: vt = 300 / 0.5 = 600

put that into the second equation: 20 = 600 x 0.866 - ½ g t²
rearrange: 20 - 600 x 0.866 = - ½ g t²
simplify: 499.6 = ½ g t²
simplify: 999 = g t²
simplify: 999 = t²
solve: t = ± 10 seconds

At t = 10 seconds we now can figure velocity:

300 = vt (0.5)
becomes: 300 = v (10)(0.5)
which gets us: v =  60 m/s

CHECK:

x = vt cos θ = (60)(10)(0.5) = 300
y = vt sin θ - ½ g t² = (60)(10)(0.866) - ½ (9.81) (10)² = 520-490 = 30


NOW, we could do a similar thing with the other variables (v or t), but not all variations are possible. So, really it is just a matter of playing with the original (idealised) equations to get what you want!

BTW I have heard of high-tech artillery pieces that can be loaded and fired 9 separate times, and each time a different angle and velocity is chosen. Even though the projectiles were fired at different times (maybe 30 seconds apart?) the 9 projectiles follow their assigned paths and land simultaneously in a 3x3 grid at the target point. Wow!! I'd like to see that on your game!


"The physicists defer only to mathematicians, and the mathematicians defer only to God ..."  - Leon M. Lederman

Offline

#7 2005-10-05 05:45:58

rkman
Member
Registered: 2005-10-02
Posts: 5

Re: needed: formula for curved trajectory to hit specific target

Both of the equations listed here are helpful but the best equation to use is combining the two equations;

x = vt cos θ
y = vt sin θ - ½ g t²

From the first one, get t on its own and sub it into the second one. You don't need to take into account what the time is for your problem. The math would get a bit ugly on this, but after simplifying you should get;

y = x tanθ - gx²(1+ tan² θ)
                           2v²

So if you need to hit a target x metres away and y metres high, you can work out the angle needed for the velocity you launch it at. Or if you launch it at an angle theta, velocity v and you want to know how far away the projectile is when it is one meter high...

Offline

#8 2005-10-08 23:01:01

raffy
Member
Registered: 2005-10-03
Posts: 3

Re: needed: formula for curved trajectory to hit specific target

Thanks guys for all your help. The equations work and I will post a link when the game is launched.

Offline

#9 2006-05-18 13:42:22

chilton tigers
Member
Registered: 2006-05-18
Posts: 4

Re: needed: formula for curved trajectory to hit specific target

any one from chilton wis.

Offline

#10 2006-05-18 13:43:31

chilton tigers
Member
Registered: 2006-05-18
Posts: 4

Re: needed: formula for curved trajectory to hit specific target

can i play?>?>?>

Offline

#11 2007-02-02 12:58:02

feral
Guest

Re: needed: formula for curved trajectory to hit specific target

hey there, sorry for bumbing an old thread:

I have the following values in my 3d world:

- my current x & y angle
- the distance in meters to the target
- the height offset in meters
- the velocity of the projectile m/s

I need to calculate the angle y offset I need to add to my current angle y so that the missile will hit the target.

I have tried to make a formula but im not good at maths, Im getting confused with the above formulas too because they have t (time), but since my projectile hasn't been fired i won't have time.

Thanks for any help!

#12 2011-08-29 03:55:17

roi187
Guest

Re: needed: formula for curved trajectory to hit specific target

MathsIsFun wrote:

300 = vt (0.5)
20 = vt (0.866) - ½ g t²

the first equation gives us: vt = 300 / 0.5 = 600

put that into the second equation: 20 = 600 x 0.866 - ½ g t²
rearrange: 20 - 600 x 0.866 = - ½ g t²
simplify: 499.6 = ½ g t²
simplify: 999 = g t²
simplify: 999 = t²
solve: t = ± 10 seconds

Hi, sorry for reviving an ANCIENT thread... I have problems understanding the processes done in this equation.
I don't get why 499.6 was divided into 1/2 and g value is omitted? And lastly, how did sqrt 999 became 9.999 or 10?

Once again I am sorry, but once I get all the answers It'll help me tons.

Thanks in advance smile

#13 2011-08-29 04:39:19

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,468

Re: needed: formula for curved trajectory to hit specific target

Hi;

I don't get why 499.6 was divided into 1/2

Both sides were multiplied by -2 and some rounding was done

-499.6 * -2 ≈ 999

Then both sides were divided by 9.81 and some rounding done again to get.

100 = t^2

This gives a rough and ready answer for the post.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#14 2011-08-29 04:46:26

roi187
Guest

Re: needed: formula for curved trajectory to hit specific target

bobbym wrote:

Hi;

I don't get why 499.6 was divided into 1/2

Both sides were multiplied by -2

This isn't clear to me a bit; why we multiplied both sides by 2? Is it because we had two T variables there has a coefficient of 2? Sorry, my algebra is really that rusted. smile

#15 2011-08-29 04:52:26

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,468

Re: needed: formula for curved trajectory to hit specific target

Hi;

To get rid of the 1 / 2 you multiply by 2, because 2 * 1 / 2 = 1


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#16 2011-08-29 05:04:47

roi187
Guest

Re: needed: formula for curved trajectory to hit specific target

bobbym wrote:

Hi;

To get rid of the 1 / 2 you multiply by 2, because 2 * 1 / 2 = 1

OK I understand now. Thank you very much! smile

#17 2011-08-29 05:06:12

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,468

Re: needed: formula for curved trajectory to hit specific target

Hi roi187;

Your are welcome and welcome to the forum!


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#18 2013-02-18 06:52:27

sushanta
Guest

Re: needed: formula for curved trajectory to hit specific target

sorry for reviving this thread again smile

here in this formula
x = vt cos θ
y = vt sin θ - ½ g t²

v (velocity) is the initial velocity or a constant velocity ? will velocity changes with time ? or it remains constant ?

#19 2013-02-19 01:22:01

sushanta1991
Member
Registered: 2013-02-18
Posts: 2

Re: needed: formula for curved trajectory to hit specific target

sorry for reviving this thread again smile

here in this formula
x = vt cos ?
y = vt sin ? - ½ g t²

v (velocity) is the initial velocity or a constant velocity ? will velocity changes with time ? or it remains constant ?

In my last post i ask this.
here is the projectile i get using this formula http://imgur.com/axCKwsP

Don't you guys think for 60* angle this is Quite a large projectile ?
with a initial velocity of 10 and 60* angle it goes to 489 m, let me tell you i am decreasing the initial velocity and increasing time by 0.1 at each step.
I dont know i am doing it in right way or not big_smile
can any one suggest me any thing ?

Last edited by sushanta1991 (2013-02-19 01:26:22)

Offline

#20 2013-02-19 14:57:06

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,468

Re: needed: formula for curved trajectory to hit specific target

Hi;

with a initial velocity of 10

10 what?

angle it goes to 489 m

Maximum height? Distance? Arc length? 489 m of what?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

#21 2013-02-19 18:19:54

sushanta1991
Member
Registered: 2013-02-18
Posts: 2

Re: needed: formula for curved trajectory to hit specific target

helllo

velocity is 10 m/s

at 10 m/s it travels approximately 489 m before touching the ground, and this is quite a large distance (non practical )

I think there is no drag , that is why the length of projectile is so long.

Could you help me inserting drag in this formula
x = vt cos ?
y = vt sin ? - ½ g t²

here you can find some formula for drag, http://en.wikipedia.org/wiki/Drag_%28physics%29

and let me tell you i am little dumb in mathematics big_smile
Thanks

EDIT : I want to draw the path of projectile.

Last edited by sushanta1991 (2013-02-19 19:38:02)

Offline

#22 2013-02-19 23:32:34

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 81,468

Re: needed: formula for curved trajectory to hit specific target

Hi;

Those are two parametric equations. We called them that becuse they are both expressed in terms of t.

To graph them in that form you will need a parametric plotter.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

Board footer

Powered by FluxBB