pi day

In celebration of Pi Day, I figured that I could get around to implementing a simulation of Buffon's Needle for approximating pi. I've implemented this in client-side JS and used WebGL for rendering. It's been a while since I used WebGL directly and wrote some vanilla JS. The Mozilla docs for WebGL have tons of great examples that can be easily used as a jumping off point. This was a fun exercise, and it was interesting to work with this first hand.

The implementation is far from optimal and does all of the heavy lifting in JS. This could clearly be made more efficient, which will be left as an exercise for the reader. Play with the parameters and see how long it takes to generate a basic approximation of pi!

If you want to check out a better version of this simulation with more details on the math, check out Thomas Ogden's website.