3D-Gravity

Two posts ago, I discussed my introduction to Three.js, and now I have used it to make a 3D gravity simulator. Borrowing the physics from my 2D gravity simulator, I used the Independence of Perpendicular Components of Motion to tack another dimension to my calculations. After getting the physics working, I noticed that I had a problem: my algorithm for choosing the optimal camera position was flawed, as it would eventually end up tracking an empty screen. In an attempt to fix this problem, I changed the algorithm to auto focus on the center of mass, but even this would fail after an extended period of time. I am yet to find the optimal camera algorithm, but I have added manual camera moving tools for the meantime. Now that this was working, I decided that I wanted to try and add elastic collisions. To do this, I borrowed the algorithm from my elastic collision simulator, and expanded it to three dimensions in the same way I did the gravity. Currently, elastic collisions are working; however, I have a few false detections that I think are due to a difference in actual and rendered sphere radii. I plan to work on this problem over the next couple of weeks.

I have also spent the time to add elastic collisions to my charged particle and gravity simulators, and in the process of reviewing my code, I decided that I needed to refactor it. I have cleaned up my charged particle simulator, and I am currently working on my gravity simulator. It is important that your code is readable, so that it becomes easier for others, and even yourself to understand it. Once I finish refactoring my code and fixing the 3D Gravity simulator, I plan to start a new project, potentially showing something like natural selection. Simulators are a good way to apply what you learn in another class to computer science, deepening your understanding of both fields as well as how they relate to one another. By and by, I will write again to inform you on the progress of my projects.