pathakshashank17 / p5

Testing out p5.js

Home Page:https://pathakshashank17.github.io/p5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using p5.js

p5.js is JavaScript library aimed at simplifying canvas sketching and manipulation

Epicycles

As we can see from the demo, a practical square wave can be obtained from summing sine waves, and this approximation gets better with increase in number of terms. Try for 9 terms vs 999 terms in the demo.

demo

Monte-Carlo method for finding π

The idea behind this is draw a bunch of random points on the canvas and count the number of points falling inside the circle. The ratio of the number points inside the circle with the total number of points is equal to the ratio of the area of circle with the area of the canvas i.e π / 4

demo

Colliding Blocks method for finding π

In this method, two blocks, each with a mass ratio of 100^x, where x is an integer interact with each and a wall using elastic collision. The interesting fact is that the number of collisions gives us the digits in pi.

demo

Demo available at gh-pages

About

Testing out p5.js

https://pathakshashank17.github.io/p5


Languages

Language:JavaScript 99.9%Language:HTML 0.1%