Originally Posted By: DavidLancaster
If I have a group of soccor players, the speed at which each player can move, and a moving soccor ball. How do I calculate the time it takes to intercept the moving ball for each player?


I believe error is almost right with his diagram - I was thinking a straight trig answer, given interception is going to be a right angle intercept using a ratio of player_speed:ball_speed for the lengths. Sadly, it doesn't actually become a right angle, so that doesn't work.. \:\)

Having played around on a piece of paper, I believe the following should work:

vars: ballSpd, guySpd, (new)timefactor
vectors: ballPos, guyPos, (unit-vector)ballDir, (new)guyDir, (new)interceptPos
angle: (new)delta

delta = vec_sub(ballDir,vec_sub(guyPos,ballPos));
//delta should be the angle of divergence of ball direction from ball to guy direct.
timefactor = vec_dist(guyPos,ballPos)/(guySpd+ballSpd)/cos(delta);
guyDir = 360-vec_sub(guyPos,ballPos)-90-delta;
interceptPos = ballPos+(vec_scale(ballDir, ballSpd*timefactor);

I may have problems in there, and could provide my scribble page if neccessary, but that may help.

Also happy to take a look at code and try and get it working myself if its screwy \:\)

Don
have a great day

PS. David - did you get my PM?