Pi-Calculating Simulation Using Boxes
by wc658356 in Circuits > Computers
124 Views, 1 Favorites, 0 Comments
Pi-Calculating Simulation Using Boxes
My project uses bouncing blocks to calculate a set number of digits of pi.
Supplies
Pycharm, computer, mouse, and keyboard
Make a Prompt for the Calculation
This section of code asks for the amount of digits to calculate and provides a backup for an invalid number of digits.
Make a Window for the Simulation
This makes a window that is 1000x600 pixels and defines a font and a way to find the amount of time the simulation has been running.
Find All the Parameters of the Objects
This defines the mass, friction, elasticity, size, and hitbox of all objects in simulation
Define Traits of the Collision
This ensures that the collisions that occur in the simulations don't change the shape of the objects and that the collisions don't lose energy
Ensure That As the Simulation Continues, the Objects Keep Moving
The first part of this code compares the variable epsilon to the time left in the simulation. The next part measures the time it takes for the box to get to the wall. Then, the code finds the relative speed when compared to each other. Then it measures the time between each collision to determine if there will be another collision before the simulation ends. The last part determines the velocity if you add friction to the simulation.
Make the Screen
This draws all elements of the simulation and puts a piece of text that counts the collisions for the calculation.