Well, there it happened.
Now - as the title implies - we've decided to add collision detection and handling to the simulation.
This would of course be mostly unnecessary if we had it in a realistic simulation of the solar system, as any objects that would collide within a computable timeframe would be too small to include.
The first type of collision we'll model is elastic collision, as it's more predictable.
But simple tinkering and adding of a few new planets can yield some interesting results.
Gif of the first collision.
After adding some new planets the simulation slowed down (naturally) and we did some simple code optimizations.
While the above picture looks pretty neat, on closer inspection one might find it a bit unrealistic (even if one considers planets as billiard balls). This became much more apparent when a planet collided with the sun at an angle. The reason for this was that the code didn't take multiple dimensions into account. It simply assumed the two objects moved in one dimension (on the same line).
The solution we used was to simply let the projection of the velocity vectors on the line connecting the center of the two planets (one dimension) and let them collide, and replace the projected components of the velocity vectors with the results.
Gif of updated collision.
Inga kommentarer:
Skicka en kommentar