This code is used to show how Pi can be calculated from elastic collisions between two blocks on a frictionless surface
Before you look at my code, check out Prajwal Souza's work on this problem!!
I discovered his code soon after I made this repo, and after thinking about this problem for so long I realized immediately that his implementation is just amazing. What I appreciate the most is that we both made design decisions that make it easy for new users to play with the simulations in a web-based environment:
- His is HTML/CSS/JS, so there are literally no extra steps for you to take other than visiting his site.
- Mine is in pure Python, so I found a way for you to easily run my code using Binder. (just click the
index.ipynb
file). - I also put up a slightly modified version of this as a Kaggle Kernel, you can view the Kaggle Kernel version here.
Lastly, if you're interested in learning about Prajwal Souza's (much cooler) code, I cleaned up and modularized a fork of the repo (still even with master branch as recently as June 27, 2019). The before and after repo just exists so you can see the functionality of the website didn't change at all when I cleaned up the code (i.e. I didn't introduce any bugs). I personally find my updates easier to navigate and understand, but I'll leave it up to you to decide which method you prefer =)
Hope you enjoy!