Drop a height from down to side . Then
Mathematically, the solution for is ambiguous, since . However, in the physical situation it is clear that the desired is always acute; otherwise would try and catch by running away from it rather than towards it--a sometimes successful but always inefficient strategy. (The two solutions for are pictured in Figure 3; is always preferable to , because a smaller means is heading more directly towards the current location of . Alternately: according the representation, a smaller maximizes the length of , which represents , the closure rate between points and .)
Assuming the implementation of the function returns only the acute or right angle, the best solution for can be simply stated