Daniel's Physics Simulator

By: Daniel Carlson

CSC 471 - Spring 2017


This program allows the user create an arbitrary number of spheres and place them inside of a "glass" box. The spheres are generated anywhere you click the mouse (although they are restricted to be outside of the glass box). You can move anywhere in the world you want (using the WASD keys), and there is a blue dummy at the origin just as a way to mark where the origin is. If you want to move faster through the world, pressing the 'M' key will toggle the camera's movement speed from 1 unit per key press to 10 units per key press.

When placing spheres into the world, you can adjust both their radius and their density. Pressing the 'K' key will increase the radius of the sphere you are about to generate. The 'T' key will decrease the radius (minimum allowed radius is 0.1 units). Pressing the 'L' key will increase the density and the 'N' key will decrease the density. The spheres are all grayscale, where their color is scaled by how dense they are. The spheres with lowest density will be white; the densest will be black.

By default, the spheres that are generated will be frozen in space. By pressing the 'P' key, you will enable the spheres to act as gravitational bodies and accelerate towards one another at a rate based on their mass. By default, sphere collisions are enabled, so spheres will bounce off eachother in a realistic manner. They will conserve momentum and kinetic energy so no energy is lost upon collisions. To toggle the collision feature, press the 'C' key and the spheres will be able to pass through one another. Having collisions disabled is probably the best way to observe the spheres interacting with eacother as gravitational bodies. You can mess around with this feature in a lot of ways. You can make a couple small spheres, one medium- sized one, and one significantly larger one, and (if you're lucky) you can get them to orbit eachother in a way similar to the moon revolving around earth, which revolves around the sun. You can also just make a bunch of small "particles" and see how they all interact when particle gravity is enabled.

Another feature is that you can press the 'G' key to toggle the Earth's gravity. When you do this, all spheres will fall to the ground, bounce a few times, then settle at rest (unless they have some X or Z components to their velocity already, in which case they'll slide along the ground). It is best to use this feature when the other gravity feature is turned off (press the 'P' key to disable particle gravity first). You also might want to press the 'Z' key first, which will freeze all the spheres by making their velocities equal to zero.

Some other features: -Pressing the 'R' key will give the spehres random velocities. (technically it will add on a random velocity to their current velocity). This is best used when all the spheres aren't moving. Press this key before you enable particle gravity so the spheres don't just shoot directly into eachother. This is better for creating stable orbits. -Pressing the 'H' key will decrease the size of the glass box the spheres are in. The 'B' key will increase its size -Pressing the 'I' key will delete all the spheres you created so you can start fresh. -The lighting scheme is a point light (that is drawn in the scene as a small, white sphere). You can move the light left and right by pressing the 'Q' and the 'E' keys.