Determine angle before collision and after collision

Still needs some debugging but here is my thought process.

I calculate all angles from one point to the next excluding bad points
or -1,-1 points. I determine which direction something is heading based
on which quadrant its heading toward. If it changes direction and the
previous point was close to the border of the box then I assume a
collision and calculate that new angle. I'm still debugging but I think
this strategy should work.

I need to make it a little smarter by factoring in the turning angle and
also trying to predict the next point to see if it really does hit.
Currently I just have an offset of 5 to determine if its close enough to
the wall to collide if the next point changes its heading drastically.