How would you find the nearest side of a rectangle from outside the rectangle I am working on a side project and I'm in need of your help!
Given a rectangle of any rotation, and a point situated outside of said rectangle, how would you find the nearest side $a_1$, $b_2$?
note: I'm actually trying to find the final angle of an object that bounces against a rotated rectangle, I therefore believe that once I can identify which side the object is hitting(I know the angle of the rectangle) I should be able to find what the final angle is.
Thank you for your time.

Just compute, four times, the distance from your point to each of the four segments bounding the rectangle. And then return the min.
There are many web resources for point-to-segment distance. Here is one:
Distance of a Point to a Ray or Segment

          


