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

You are not logged in.

- Topics: Active | Unanswered

Pages: **1**

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

I just thought this was cool and worth posting about.

Heres an interesting problem I worked out for a program.

Lets say you have a target moving along a given path at a given speed, and a bow with a given firing power, from a given location. At what angle do you point the bow so that it hits the target by the time it gets there? (assume no gravity or wind resistance, assume you are firing from the origin)

I solved this problem by finding the intersections of two circles and a line. The radius of the first circle is the speed of the target (v) times t, which is the time elapsed from when the bow is fired. The center of the circle is the position of the target the instant the bow is fired. The target will travel away from that point a distance of vt before the arrow contacts it. Thus we get the equation (x - a)^2 + (y - b)^2 = (vt)^2 where a and b are the x and y coordinates of the target the instant the shot is fired.

The target is traveling at a given direction θ, thus you can use convert it to a linear equation using tan θ for the slope and inserting the coordinates a and b to find the y intercept. So you can write its path as a linear equation y = mx + c

the arrow will travel t seconds times the firing velocity of the bow (V) so it will travel tV units away from the origin before it hits the target. Thus the equation of its final location (when it strikes the target) is x^2 + y^2 = (Vt)^2.

The only variables we have are x, y, and t. The rest are given. Again t is the time ellapsed from firing until impact, x and y are the coordinates of where the target and arrow collide. We have thee equations and can now solve.

I took the first equation (x - a)^2 + (y - b)^2 = (vt)^2 and divided it by x^2 + y^2 = (Vt)^2. This gives you [ (x - a)^2 + (y - b)^2] / [ x^2 + y^2] = v^2 / V^2

You can substitute y with mx + c, cross multiply and solve using the quadratic equation. :-) This gives you the values of x and y to aim at, so you can use inverse trig functions to find the angle to point the bow.

The only real problems are, when the target is moving vertically, it has no linear equation. The value of y is given from the getgo and you have to work the problem differently. (I hate branching functions :-( )

But even if you use an alternate formula for that, due to limited variable storage accuracy, the accuracy of the function tends to decrease when the targets direction gets very close to 90 or 270 degree's (where the slope is undefined). I solved this in a very peculiar manner. I checked to see if the tangent of the targets path was greater then 1 (more then 45 degree's steep) in which case, I exchanged the x and y coordinates and converted every angle to (90 - angle), mirroring the whole problem about the line y = x. This turned vertical lines to horizontal ones. Finally when you get the resulting values of x and y, exchange them again and you've solved the problem. :-)

The last problem is the quadratic formula gives us two answers. :-( This is because the formula doesn't know if the velocities are positive or negative. (thanks to the squaring). I used some if statements to solve this but I'm not particularly thrilled with the method I used. A little inellegant. Any suggestions?

I have managed to get it working and it works incredibly well. I used two circles of the same size to test, even at great distances, the object intercepted the target and COMPLETELY ecclipsed it, the accuracy was eerie!

Anyways, I thought the same problem could be worked in 3d using the equations of two spheres and a 3d line. But vertical lines really do cause trouble. :-/

A logarithm is just a misspelled algorithm.

Offline

**George,Y****Member**- Registered: 2006-03-12
- Posts: 1,306

too long...

I think a way to solve your problem is like this

find the function of target distance from origin at time t

d(t)

find the displacement of the arrow after time t

s(t)

solve

d(t)=s(t)

solved t is hitting time

Now that you've got t, you know the position of the target when hitted, thus you'll find an (several) angle(s).

**X'(y-Xβ)=0**

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

isn't that essentially what I did? the displacement of the arrow will be Vt, but its no location will require the distance formula which is the same equation as the equation of a circle. I can't see how the displacement could be expressed without using either x,y or polar coordinates which both bring in an additional two variables. Thus you'll have three variables t, x, and y and need more then two equations to solve.

And by the way, not sure I understood you but if d(t) stands for the distance the target traveled, and s(t) stands for the the distance the arrow traveled, then finding the solution to d(t) = s(t) will not give you the answer. You need to find d(t)/s(t) = v/V which is what I did.

Perhaps you could provide a more detailed example of how you'd solve it. I'd love to see a simpler way to solve it. I couldn't find any.

*Last edited by mikau (2006-06-08 03:31:34)*

A logarithm is just a misspelled algorithm.

Offline

**George,Y****Member**- Registered: 2006-03-12
- Posts: 1,306

Get the vector function of t for target

At t=0, target (a,b)

suppose the target velocity is (p,q), where q/p=tanθ

then the function is

(a,b)+t(p,q)= (a+pt,b+qt)

then get distance function, which means distance from where arrow is shot.

d(t)=√[(a+pt)²+(b+qt)²]

s(t)=wt, where w is the SPEED of the arrow. No matter at what angle it was shot, after time t, it is wt far from shot point.

√[(a+pt)²+(b+qt)²]=wt

**X'(y-Xβ)=0**

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

I see now, your finding the distance of the targets final position, from the origin. Not the distance from its original location.

mmm...looks good. It still requires the quadratic formula, however it should give you a positive & negative value of t, the positive is the answer. Thats a definite plus.

That vector stuff is very cool. My trig and calc book only discussed vectors briefly. It was enough to understand what you said but I'm not too experienced with them. Must, get, book!

(edit) Just retyped the formula, it works like a charm! And no more obnoxious quadratic ambiguity. The formula is a lot shorter too.

Thanks for the tips, George Y!

*Last edited by mikau (2006-06-08 05:33:21)*

A logarithm is just a misspelled algorithm.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,558

Apparently modern-day artillery pieces can do a very clever and powerful thing.

The scene: a corner of a desert; a large artillery piece, a few men and some vehicles.

The men load a shell, the piece is elevated and rotated, and then at a precise moment the shell is fired. The shell arcs into the sky, but the men continue working like clockwork. Another shell is loaded and the process is repeated. Again and again for a total of 9 times. The men then enter the vehicles and move on, to avoid a counterstrike.

At this point a viewer from above the planet would see each shell following its individual arc. Some high, some low, but more-or-less heading in the same direction.

Scene change: a group of tanks moving across the desert. The man in the lead tank yells "incoming", but they don't stand a chance. The desert erupts in 9 simultaneous explosions in a perfect 3x3 grid.

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

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

are all 9 shots fired by the same cannon? :-O

I said it before and I'll say it again:

Ah...the power of math...

A logarithm is just a misspelled algorithm.

Offline

**George,Y****Member**- Registered: 2006-03-12
- Posts: 1,306

It's a pleasure to share with you one of the greatest inventions in math- the vector concept, mikau!

**X'(y-Xβ)=0**

Offline

**Patrick****Real Member**- Registered: 2006-02-24
- Posts: 1,005

MathsIsFun - Maths is indeed great/fun! Thanks for sharing!

Support MathsIsFun.com by clicking on the banners.

What music do I listen to? Clicky click

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

George,Y wrote:

It's a pleasure to share with you one of the greatest inventions in math- the vector concept, mikau!

Indeed, I really need to get a book on vector math, its really cool and fun!

A logarithm is just a misspelled algorithm.

Offline

**Ninja 101****Member**- Registered: 2006-02-20
- Posts: 936

Statement:

I enjoy using projectile weaponry.

Example:

Crossbows and handguns

Stating the obvious:

On firing ranges of course.

Chaos is found in greatest abundance wherever order is being saught. It always defeats order, because it is better organized.

Offline

**All_Is_Number****Member**- Registered: 2006-07-10
- Posts: 258

MathsIsFun wrote:

Apparently modern-day artillery pieces can do a very clever and powerful thing.

The scene: a corner of a desert; a large artillery piece, a few men and some vehicles.

The men load a shell, the piece is elevated and rotated, and then at a precise moment the shell is fired. The shell arcs into the sky, but the men continue working like clockwork. Another shell is loaded and the process is repeated. Again and again for a total of 9 times. The men then enter the vehicles and move on, to avoid a counterstrike.

At this point a viewer from above the planet would see each shell following its individual arc. Some high, some low, but more-or-less heading in the same direction.

Scene change: a group of tanks moving across the desert. The man in the lead tank yells "incoming", but they don't stand a chance. The desert erupts in 9 simultaneous explosions in a perfect 3x3 grid.

By utilizing different firing elevations, azimuths and charges (amount of powder used) a single howitzer is capable of firing two rounds individually that hit the same target simultaneously. I've never seen it done with more than two rounds. The maximum charge and the loading time for each round (30 seconds to a minute) appear to be the limiting factors for traditional artillery, while an inability to vary the charge (I believe) limits rocket artillery to two rounds on target fired from the same tube. (I'm not sure how quickly rocket artillery rounds can be reloaded; it may not be fast enough to make two round on target at the same time possible).

--All Is Number <---Once operated 155 mm howitzers for a living

*Last edited by All_Is_Number (2006-07-22 04:53:11)*

*You can shear a sheep many times but skin him only once.*

Offline

Pages: **1**