___ _____ ______ ________
|\ \ |\ _ \ _ \|\ _____\
\ \ \ \ \ \\\__\ \ \ \ \__/
\ \ \ \ \ \\|__| \ \ \ __\
\ \ \____\ \ \ \ \ \ \ \_|
\ \_______\ \__\ \ \__\ \__\
\|_______|\|__| \|__|\|__|
In this project, I set out to create a simulation of gravity, ignoring most other interactions. I have some very interesting results from this project, as I was able to simulate the solar systems orbit with great accuracy.
This fact becomes so much more satisfying once you learn that I inputted the real masses of celestial bodies, their real distances, and based it all on the equations:
$$ F_g = G \frac{m_1 m_2}{r^2} \qquad F_c = \frac{mv^{2}}{r} \quad {\text{Where}} \;F_c\; {\text{is the force of gravity in our case.}} $$
Let's see the custom sandbox in action:
Anywhere I left click on the screen generates a particle with a random mass, they all have the same density, so they render their radius based on mass. Once there are multiple, they immediately begin enacting forces upon each other and form small 'globs'.
I can also create a pre-defined model of particles with set masses, velocities, and positions to simulate known systems like the Earth and the Moon seen below with its parameters all derived from real factual values.
$$ m_{\text{earth}} = 5.972 \times 10^{24}{\text{kg}} \qquad m_{\text{moon}} = 7.347 \times 10^{22}{\text{kg}} \qquad d_{\text{moon}} = 3.844 \times 10^{8}{\text{m}} \\[15pt] G = 6.674 \times 10^{-11}{\text{m}}^{3}{\text{kg}}^{-1}{\text{s}}^{-2} \qquad v_{\text{moon}} = 1.018 \times 10^{3}{\text{m/s}} $$
This model is really quite impressive, and goes to show just how powerful the fundamental equations of physics truly are. Of course this also scales up to simulate the solar system as we know its masses, distances, and periods to be:
This project heavily depends Verlet Integration to calculate the next positions of each particle. There is a for loop that calculates the force interactions on each particle, then it uses trigonometry (although now that I've learned Linear Algebra that may have been a better method) to calculate the sum of the forces in the X and the Y directions. Then, Verlet Integration uses those forces and its own known mass to calculate where next the particle should be after the time step, delta_t.
Both the sandbox and the custom models have some keybinds that are useful for navigating the space, which can be found on the Github page along with all of the code used in this project. Be sure to fully read the README to get all the information you need to start simulating! Thank you for reading.