This was a class project where we learned to utilize 3D mathematical operations within an OpenGL Rendering JavaScript framework. We first learned about basic bounce physics. The next step was creating basic orbiting physics for planetary rotation around a sun, and moon object rotating around the planet.
The ball bounce is bounded by 4 sides, a floor, and a ceiling. Bouncing on the floor will not dampen the ball velocity. Bouncing off the ceiling will dampen the velocity by a factor of 0.8f. Bouncing off a wall will dampen the velocity by a factor of 0.6f. When the balls collide with each other, their respective reflection vectors becomes their respective velocities.
The ball orbit is pretty straight forward. The planetary bodies rotate around the sun based on an initial velocity and direction which are then affected by the distance from the sun, and the sun's gravitational pull. The smaller moons (2 per planet) operate along the same lines; They are giving an initial velocity and direction, then are affected by the gravitational pull of their specific planet. Planets are affected by the sun's gravity, but not each others gravity. Moons are not affected by the other planetary bodies or sun.