Coding Challenge #139: Calculating Digits of Pi with Collisions
Happy Pi Day! To celebrate I attempt to compute the digits of Pi using the “collisions” method, thanks to 3Blue1Brown for the idea! Code: https://thecodingtrain.com/challenges/139-calculating-digits-of-pi-with-collisions
🕹️ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/4FuKfd-LJ
🎥 Previous video: https://youtu.be/TDQzoe9nslY?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🎥 Next video: https://youtu.be/uH4trBNn540?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🎥 All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References:
📄 Playing Pool with Pi: https://www.maths.tcd.ie/~lebed/Galperin.%20Playing%20pool%20with%20pi.pdf
💥 Elastic Collisions: https://en.wikipedia.org/wiki/Elastic_collision
📓 Euler Method: https://en.wikipedia.org/wiki/Euler_method
🥧 Additional Pi Day Code Examples: https://github.com/CodingTrain/Pi-Day-2019
Videos:
👁️🗨️ The Block Collision Puzzle: https://youtube.com/playlist?list=PLZHQObOWTQDMalCO_AXOC5GWsuY8bOC_Y
🔢 Pi and Bouncing Balls: https://youtu.be/abv4Fz7oNr0
⭐️ Member-Exclusive Pi Day Prep: https://youtu.be/yii2P7WVfNE
🔴 Coding Train Live 172: https://youtu.be/78ZthTGcdPw?t=1398s
Related Coding Challenges:
🚂 #95 Approximating the Value of Pi: https://youtu.be/5cNnf_7e92Q
🚂 #140 Leibniz Formula for Pi: https://youtu.be/uH4trBNn540
🚂 #156 Peeking Inside Pi: https://youtu.be/MEdpRYyjz_0
🚂 #161 Estimating π from Random Numbers with Euclid's Algorithm: https://youtu.be/EvS_a921dBo
🚂 #169 Pi in the Sky Game: https://youtu.be/_H9JIwWP7HQ
Timestamps:
0:00 Introduction!
1:51 Basic code of the structure
7:00 Simulating elastic collision between two blocks
12:03 Simulating the wall
13:59 Adding the clack!
14:29 Counting the collisions!
18:09 Adding timesteps to control approximation
24:12 Adding constraints to speed up animation
26:47 Watching collisions upto 11 digits of pi!
28:46 Other methods to simulate elastic collisions and things to try!
30:50 Fake outro (and a special Pi Day song!)
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
🚂 Website: http://thecodingtrain.com/
👾 Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide
🚩 Suggest Topics: https://github.com/CodingTrain/Suggestion-Box
💡 GitHub: https://github.com/CodingTrain
💬 Discord: https://thecodingtrain.com/discord
💖 Membership: http://youtube.com/thecodingtrain/join
🛒 Store: https://standard.tv/codingtrain
🖋️ Twitter: https://twitter.com/thecodingtrain
📸 Instagram: https://www.instagram.com/the.coding.train/
🎥 Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🎥 Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
🔗 p5.js: https://p5js.org
🔗 p5.js Web Editor: https://editor.p5js.org/
🔗 Processing: https://processing.org
📄 Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new
#3blue1brown #elasticcollision #piday #eulermethod #p5js #javascript