# 2D vehicle collision detection and rotation

I'm attempting to make a simple 2D car game from scratch, but I can't figure out the collision detection between a vehicle and a road. The vehicle should also rotate appropriately to its position on the road, as following (the vehicle is a rectangle and the road is a curve.):

As you can see, the vehicle collides with the road (but before it's being drawn, so that a user doesn't see that collision). Once the intersection is detected, the vehicle needs to be pushed away and rotated appropriately, as it's driving upwards:

The problem is the vehicle may have any rotation (assuming it won't be so fast to go through the road, missing the collision detection), as well as the road's curve may be directed towards any axis, making the algorithm hard to cover any possible situation.

Have you any idea how to achieve that?

• This looks similar to another question that was asked recently. Reviewing the answer there may give you some useful leads. – DMGregory Apr 25 '19 at 13:52
• @DMGregory Thanks for your reply. However, the question you mentioned doesn't cover the collision detection, but the math and physics in general. – Michael1996 Apr 25 '19 at 14:08