# hunter and target - meeting point

This topic is 4441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have 2 objects in 3d space: hunter and target I have hunter position (H), hunter direction/speed vector (Hs), target position (T) and target speed (length(Ts)), not vector. I need to find nearest meeting point which hunter should fly to to meet target in minimum time I have intersection of this two lines: H+t*Hs = T+t*Ts (where t is 'time' in program cycles), but I have neither t nor Ts (only its length) to find the solution. How should I solve it? Thanks a lot!

##### Share on other sites
I think you have insufficient information. If you don't know the direction that the target is moving in, how can the hunter know where to turn to intercept? There needs to be some other constraints. Also, you have the hunter's initial velocity only right? Based on your question, it can change directions but is it's speed constant?

I'm guessing you might know the previous target position. If so, then you can determine the last velocity direction of the target and move the hunter in the direction to intercept. You say you don't know t, but you should have that if it is program cycles.
delta_T = T2 - T1; // change in target positiondelta_t = t2 - t1; // change in time (this should just = 1 if you are measuring time in program cyclesTs1 = delta_T/delta_t; // target velocity is the change in position over time

So now you know which direction the target was moving in and you can move the hunter to close in. But from that you can't determine the meeting point without running to intercept unless there are other constraints (like constant velocity target).

But unless you have certain rules, it will always be possible that you would never intercept. For example, if the target is too fast.

Hope that helps some, but I think we need more info somehow.

##### Share on other sites
The common situation is that you know the target's velocity (the vector) and the hunter's speed, and you need to know in what direction the hunter should move. This was discussed in this thread.

If this is not what you need, try to explain the situation in a little more detail. A simple example that can be solved by hand would be nice.

##### Share on other sites
I have both hunter direction vector (Hs) and its speed (length(Hs)).

Alvaro, the topic you recomment is the one I'm looking for - but I need implementation for 3D space and I'm not familiar with C++ notation 8-(
Could you please recommend topic / article devoted to the problem?

##### Share on other sites
Besides providing code, I also explained the computations in that thread. The 3D and 2D cases are identical.

I don't know of any tutorials that explain this problem. Let me know what part of my description you don't understand (or don't know how to code) and I'll try to explain it better.

What programming languages do you know?

##### Share on other sites
Alvaro,
thanks a lot, your step by step description in that topic is VERY good. I use VB and it seems to me that I'll be able to convert C example there.
But I wonder what if
- target speed is greater than hunter speed?
- target speed is 0?
what will happen with the calculation in this cases?
should I track (b*b-4*a*c) < 0 case (and when it could happen?) or it is impossible here?
thanks a lot!

##### Share on other sites
What I posted in the other thread was assuming bullets move faster than targets. If this is not the case, you can end up with no solutions, two positive solutions or two negative solutions. You should check the sign of the discriminant (b*b-4*a*c) and pick the smallest positive root, if there is one.

##### Share on other sites
Alvaro, thanks a lot for reply, but in the other thread you said that the larger solution is the one we are interested in.
So which root should be taken?

Yes, I need to handle case when target moves faster than hunter (it's ships, they move slower than bullets) - how to determine if hunter can't intercept target basing on the equation?

thanks a lot!

##### Share on other sites
Quote:
 Original post by krio123Alvaro, thanks a lot for reply, but in the other thread you said that the larger solution is the one we are interested in.So which root should be taken?

You want a positive root. If you have two, it's up to you which one you want to use, but presumably you want to hit your target as soon as possible.

What I posted in the other thread, as I said, is assuming bullets are faster than targets. In that case there will be a positive solution and a negative solution, so we want the positive one.

Quote:
 Yes, I need to handle case when target moves faster than hunter (it's ships, they move slower than bullets) - how to determine if hunter can't intercept target basing on the equation?

If there are no positive solutions, the hunter can't intercept the target.

1. 1
2. 2
Rutin
19
3. 3
4. 4
frob
13
5. 5

• 9
• 17
• 11
• 9
• 17
• ### Forum Statistics

• Total Topics
632604
• Total Posts
3007369

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!