Find the better intersection of two moving objects

前端 未结 4 761
灰色年华
灰色年华 2021-02-19 07:03

I would like to optimize dramaticaly one of my algorithm, i will try to explain it the best way that i can.

The subject

We are in a 2D euclidian system at the

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-19 07:24

    Since the speeds are fixed, this should be solvable using the idea of parallel navigation. Think of it this way. At time 0, there is a line between O1 and O2 (the LOS, or line of sight). If O2 follows the optimal intersect path, then at time 1, the line between O1 and O2 will be parallel to the time 0 LOS. Since you have O2's speed, you can calculate the distance it will travel between time 0 and time 1, and from that can calculate where that intersects the time 1 LOS. Think of scribing a circle around O2's original position with radius equal to the distance it will travel in that interval of time. The intersection(s) of that circle with the second LOS will contain the solution. If there is no intersect, there is no solution. The beginning of this online book has a diagram and formulas that show the concept:

    http://www.crcnetbase.com/doi/abs/10.1201/9781420062281.ch2

    This problem has real world applications where you may also find this solution talked about. For instance submarines can use this to plot and maintain an intercept course with their target by keeping the LOS bearing to their target constant as they close on their target.

    Edit:

    enter image description here

    This diagram shows what I'm talking about. This can be solved using trigonometry except for the special case where the target O1 is moving directly towards or away from the missile O2 (which can be solved trivially).

    In the diagram above we can take some arbitrary small amount of time. During that time t1, O1 will have traveled distance b, and O2 will have traveled distance f. The line between O1 and O2 at time t0 is parallel to the line between O1 and O2 at time t1. Since we are given the initial positions of O1 and O2 we know distance d, and since we are given O1's direction, we can simply calculate the angle A.

    So given A, b, f, and d, using the law of Cosines,
    a = sqrroot(c^2 + b^2 - (2cb * cos(A)))
    and
    B = arccos((a^2 + c^2 - b^2)/2ac)
    Using the law of Sines
    E = arcsin((a * sin(B))/f)  or the ambiguous value of 180 - that value
    and with that
    BC = 180 - E   (because C = 180 - B - E so C+B = 180 - E
    

    with BC we have the solution, and the any other aspects of the triangle of the initial locations of O1 and O2 and the intersection point can be similarly calculated. It's been many years since I used my high school trig, so there may be a simplification of this that I've missed, but this hopefully explains the solution approach I initially described.

提交回复
热议问题