-
Pattern created when a ball bounced realistically in a square
-
Pattern and graph detailing the convergence of a ball's path when it bounces unrealistically in a square
-
Pattern and graph when starting angle is decreased and starting position is shifted to the right
-
2 balls bouncing in a custom heart-shaped polygon
Many thanks to our beloved mentor, 'Math Guy', who was vital for helping us not crash out after every inconvenience. He worked with us through our problems in a way that was very comprehensive and did it in style. Also thank you to Charlie, the dog, who gave us good luck before our demo and also helped us not crash out during said demo.
At the beginning of the hackathon, neither of us knew how to animate using matplotlib, but by the end we really got the ball rolling and were able to create animated graphs describing our billiard table's behavior. We had to study up on a lot of math that was above our pay level and ended up watching and reading a lot of stuff made by some very smart people.
The first challenge was difficult for us and we spent all friday working on it. This is mainly because our original hypothesis on how the ball would roll turned out to be not true. We didn't consider this and ended up doing all of the math by hand only to realize that the trajectory of the ball wasn't actually supposed to converge into a rectangle immediately. Another issue that we discovered on our first day is that python does it's calculations in radians, and not degrees, after at least a half hour of confusion.
We took a special interest in the first challenge and how the math around it works. Maybe it's because of our failed hypothesis and wondering what's going on there. We set up an graph that goes beside challenge one and tells us where the ball will be hitting on the right most edge. There are 2 screenshots of this chart in action attached. We wanted to find the curve of the initial contact with the rightmost wall compared to when the ball will just start hitting the same point over and over.
Our algorithm we made for the 'warm up' was not adaptable to the second half of the challenge, as we just used trig for it and assumed the ball would bounce off of the wall only once. So, starting saturday morning, we made a whole new algorithm, this time, inspired by the way video games code physics. We have 3 components to this algorithm: we give the ball it's velocity so that it moves, then the ball will detect whether it will collide with a wall by shooting a raycast(line) the size of it's radius ahead of itself and finally, if a collision is detected, the velocity vector is reflected along the wall using vector projections. This algorithm works for all polygons, and we did make it work with a 35 sided 'circle'. Although it does have some issues with corners.
Log in or sign up for Devpost to join the conversation.