# Finding an interception point?

1. Jul 7, 2008

### The Guardian

Sorry I wasn't sure which forum exactly to put this into.

I'm writing a computer game, and I have an object departing from 0,0 on a 2D plane with known and constant velocity and slope. X and Y will always be positive.

I also have a point on that plane with different but known (and constant) velocity.

What I'm not sure about is how to find the interception point that has the least amount of time. I know if I simply move on a perpendicular slope from the known X,Y coordinates it will be the shortest time for that object but not for the object traveling from 0,0 necessarily.

So basically I need the point at which the time for both objects to reach that point is the same.

2. Jul 7, 2008

### Zizy

Ummm if I got it right you actually want to know in which direction to go with the other point to intercept first one as soon as possible. Your trajectory will surely be a straight line.
If you draw a line between two originating points you get a triangle. One angle is known, all you have to do is write down the equation. (a^2=b^2+c^2-2*b*c*cos(fi)), fi is the angle between b and c.
You get an equation for time. From this, calculation is very simple...

3. Jul 7, 2008

### The Guardian

Yes I suppose if I know the angle I can figure out the point of interception. And of course there is the possibility that it can't be intercepted.

I wasn't really sure how you were using the variables so I drew a diagram in Paint.

Point s is the starting point of the second object. Point p is the point of interception.

We know the length of c, and we can know the angle A. We also know the velocity along the paths a and b.

What I need to know in the end is: if an interception is possible, the length of a, and the coordinates of point p.

File size:
6.3 KB
Views:
193
4. Jul 8, 2008

### Zizy

Length of a = v2*t, b=v1*t, this reduces problem to just one variable, t... if there exists some sensible solution of t (real, positive), this problem has a solution. Calculation of a and p is easy when you have t.
(condition for having a solution for t is that v2^2 >= v1^2*(sin(fi))^2. However, if v2^2=v1^2 and sin(fi)=1, problem has no solution)

5. Jul 8, 2008

### The Guardian

OK, so if I plug those lengths in and then run it through the quadratic equation I can solve for t right?

t = ( -2 * v1 * Cos(fi) +/- sqrt( (2 * v1 * Cos(fi))2 - 4 * (v12 - v22) * c2) ) / 2 * (v12 - v22)

Look right?

6. Jul 8, 2008

### Zizy

Seems right. You could simplify equation a bit if you require more speed when running your game.

7. Jul 8, 2008

### The Guardian

Cool thanks! I don't really need to speed it up I think it'll run fine, but out of curiosity how would you simplify that given that you don't know v1, v2, c, or the angle at compile time, only at run-time?

8. Jul 8, 2008

### The Guardian

... so t is mostly dependent on the actual velocities of the two objects and the angle has very very little effect, right? If I use c=240, v1 = 20, v2 = 100 and fi=10° I get ~2.45 seconds, but I get the same if I set fi=40°. On the other hand with fi at 40, I do not have a legal value with which find find angle B which I assume means that an interception is impossible? (makes sense given the larger angle)...