Angled Bounce Engine

This project proposed a moderate challenge to me. I had to think of a way to have a ball make realistic bounces off of freeform surfaces. I created a pair of "for" loops that check for collisions on the left side and right side of the ball (as displayed by the black dots). Then I used the two balls' locations to determine a normal vector of the surface. With its initial velocity vector and a normal vector I was able to produce a final velocity vector to launch the ball off the surface. In the corner the vectors displayed are final velocity, normal, and initial velocity in that order.