0

Hi, I have a projectile and a target.
Both objects have: Vector2D velocity and Vector2D position. How do I find the predicted position just using the target's position and velocity, together with the projectile speed?

2
Contributors
8
Replies
29
Views
2 Years
Discussion Span
Last Post by HuePig
0

Assuming the velocity doesn't change, the position after time t is just
current position + velocity * t

You don't need speed as well because velocity, by definition, includes speed (velocity is speed and direction).

0

what if the velocity of the target change? Also, is there a solution that does not include a clock?
I've tried that solution and my projectile is always behind.

Edited by HuePig: attached an image

Attachments Capture.PNG 13.31 KB
0

If you want a predicted position for moving things then you must have some kind of clock, because the predicted position will change over time.
If the velocity of the target changes then it becomes harder. Is the change predictable (eg following a trajectory under gravity) or does it change unpredictably (eg performing avoidance tactics)?

0

I tried using a clock. the problem now is the whole thing turns to 'pursuit'. The projectile is not doing a straight trajectory and instead turning to the heading of the target.

0

In that (simple) case you have two equations for the position at time t Pt, given the initial position p and the velocity
pt1 = p1 + v1.t
pt2 = p2 + v2.t

Ifthe two obects are going to collide then their positions must be the same at the same time, ie
pt1 = pt2 = p1 + v1.t = p2 + v2.t

now you can just solve those simultaneous equations to find the point of collision (pt1 or pt2) and the time at which they collide (t).
If there is no solution then it means the two objects will pass by without colliding.

0

Hi, sorry it took me too long to get back to the problem....
I get what you're saying.. but I have to use time = distance / velocity.
So, Distance1 / Velocity1 = Distance2 / Velocity2
then sqrt((x - x1)^2 + (y - y1)^2) / Velocity1 = sqrt((x - x2)^2 + (y - y2)^2) / Velocity1
I just have to find (x, y).

Edited by HuePig

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.