I would like to optimize dramaticaly one of my algorithm, i will try to explain it the best way that i can.
We are in a 2D euclidian system at the
You appear to be over-thinking the problem, it should just be simple geometry.
Leaving aside the problem of how you define the nearest point, let's solve for the situation where the desired point is midway between PA
and PB
.
We have to assume a time period for the entire cycle, let's call that T
.
PI = (PB - PA) / 2; // simplified
TI = T / 2; // simplified
[decompose all formulae for the x and y coordinates separately].
There are relatively simple formulae for determining the closest intersection of a point (PC) with a line (PA -> PB), although how that's defined is complicated when that line isn't infinitely long.
Then you need:
V1 = (PB - PA) / T; // O1's velocity
V2 = (PI - PC) / T; // O2's velocity
These last two lines don't depend on the earlier assumptions - if you know the interception point then the velocity is simply the distance travelled divided by the time taken.
Hence unless you impose some additional constraints on V2, there is always a solution and it's calculated in a few trivial math operations.