## Intercepting a target

A target is at position P1 moving along a velocity vector (2D) V1.

A projectile needs to be shot out to intercept the target. The projectile starts at P2 and has a velocity magnitude of |V2|. So the question is, where is the point of interception, provided one exists?

Here is where I'm getting stuck, essentially you can use the law of sines as described by the sub torpedo article on wikipedia:

http://en.wikipedia.org/wiki/Torpedo_Data_Computer

Essentially if you let alpha be the angle between the vector of the target velocity and the initial positions of the projectile and target, then you can compute beta, which is the angle between the position vector and vector which the projectile should be shot along:

beta = arc sin(|v1| / |v2| * sin(alpha))

Then using beta you can compute what the actual component vector is of the projectile vector (making adjustments for orientation as necessary).

Here is the problem I have though: the only solutions this technique gives is for when beta < 90 degrees. However, there should be some cases where beta is > 90 (i.e. the projectile has to almost move with the target and exploit the fact that it starts off ahead to intercept it). So this solution is incomplete.

So, how can I solve this problem in a way that finds solutions where beta would be > 90 degrees?

The other approach I'm thinking of doing is an iterative optimization of a of error function, but it'd be nice if there was a straightforward solution.

Thoughts?

We wrote a blog post about just this thing: http://howlingmoonsoftware.com/wordpress/?p=358

The solution I show uses only a few dot products and a single square root. I usually try to avoid using inverse trig functions as I often find that I run into obnoxious domain issues and a lot of needless conversions to and from polar coordinates.

The solution I show uses only a few dot products and a single square root. I usually try to avoid using inverse trig functions as I often find that I run into obnoxious domain issues and a lot of needless conversions to and from polar coordinates.

Scott Lembcke - Howling Moon Software

Author of Chipmunk Physics - A fast and simple rigid body physics library in C.

Cool, I'll check out the link. Thanks.