I've been working on implementing a collision system for my racing game using Three.js. Following a helpful guide, I'm trying to calculate the final linear and angular velocities post-collision between two cars.
Here's the link to the guide I'm referencing.
My main challenge lies in determining the correct direction for the normal vector. The guide suggests using the vector n perpendicular to the impacted body B's edge and pointing outward from it. I've found this method useful:
How do I calculate the normal vector of a line segment?
While finding the numerical value of the normal is straightforward, ensuring that my program uses the proper direction poses difficulties. Specifically, I want to use the blue normal instead of the red one. Here's an illustration to clarify my concern.