# Finding the site of the potential collision between 2 vehicles

I've been trying to implement the unaligned collision avoidance steering behavior. I get what needs to be done on a high level, but struggle with the maths behind it.

On Craig Reynolds site, he describes

Collision avoidance is obtained for a vehicle by considering each of the other vehicles, and determining (based on current velocities) when and where the two will make their nearest approach. A potential for collision exists if that nearest approach is in the future, and if the distance between the vehicles at nearest approach is small enough. The nearest of these potential collisions, if any, is determined. The vehicle then steers to avoid the site of the predicted collision.

For the trajectory of the vehicles, I simply store a velocity vector (x, y), and to change it an acceleration vector is used. The collision avoidance behavior should return a force (in the form of a vector).

How you would find the nearest approach (Isn't this just where they collide?) and the site of the predicted collision?

• It looks like that description already breaks it down into simple steps. 1. Consider each pair of vehicles. 2. For that pair, calculate the closest approach in their current trajectories. 3. Check if that closest approach is in the future, and too close. 4. If so, use an avoidance steering behaviour to steer away from that point. So: is there a particular step in the process you're having trouble implementing based on this description? The more precisely you can identify the problem, the better the answers you'll tend to get, and faster too. Commented Mar 21, 2020 at 13:45
• I'm struggling most with what you described as steps 2 and 3. Do you recommend I open a new question? Commented Mar 22, 2020 at 3:08
• No, but you can edit this question to explain that specific problem in more detail. What shapes are your trajectories, or how do you parametrize them? With that information, we can help you solve the equations for finding the closest approaches. Commented Mar 22, 2020 at 3:10
• @DMGregory Thanks for your advice! I've edited my question accordingly. Commented Mar 22, 2020 at 5:45
• We need a little more yet. How do you turn or accelerate your vehicles? That also affects the shape of their trajectories. The less you tell us at a time, the more likely we'll have to pause to ask follow-up questions, so err on the side of over-sharing. Ideally, if we have enough information to completely reproduce your exact situation, we can even test our solutions to be sure they work for your needs. Commented Mar 22, 2020 at 11:14