Skip to content

Approximating digits of PI with box Collisions in C++ visualized using SDL2.

License

Notifications You must be signed in to change notification settings

achaval-tomas/Pi-With-Box-Collisions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pi-With-Box-Collisions

Approximating digits of PI with box Collisions in C++ visualized using SDL2.

This is one of my first Coding Projects in C++, so it's far from perfect. Feel free to contribute improvements and optimizations via Pull Requests.

The goal is to approximate N digits of Pi by calculating the amount of perfectly elastic collisions of a 1kg Box with a 100^(N-1)Kg box and a wall.

Real perfectly elastic collisions are calculated and it's optimized to perform faster with bigger masses.

There's music that I thought fit well with the project but it can easily be removed by deleting all SDL_Mixer related code.

Full Run-Through

Pi-Approx-Preview.mp4

How to run the simulation

On windows

start bin/release/main

On Linux, or WSL

./bin/release/mainLinux

How to re-compile it

On windows with mingw

g++ -c src/*.cpp -std=c++14 -O3 -Wall -m64 -I include -I /bin/release && g++ *.o -o bin/release/main -s -L /bin/release -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer

On Linux, or WSL

g++ -c src/*.cpp -std=c++14 -O3 -Wall -m64 -I include -I /bin/release && g++ *.o -o bin/release/mainLinux -s -L /bin/release -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer

Note: Necessary Libraries are included in bin/release. If this doesn't work for you, you may need to Download and install SDL and/or mingw

About

Approximating digits of PI with box Collisions in C++ visualized using SDL2.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages