Longish post warning.

Alright so I debated necroing an older thread that conveniently reminded me the last post was from me 990 days ago. It was slightly tangential to the topic(Realism in Battlescape) and I wanted a more focused discussion on orbital mechanics, specifically the planetary motions about the unnamed(afaik) star.

This is a pretty specific question for @InovaeFlavien regarding how the physics simulation calculates planetary orbits and motion and how its applied. I debated pming you privately but I felt why not open it for discussion because for me itâ€™s an interesting topic.

It is my understanding that at the heart of the physics sim is an n-body simulation that calculates absolute distances and applies the force to each individual object. In addition to this, I remember being told that the planets will *not* orbit around the star due to compounding errors in their positions and velocities which is a valid concern. If this is still the case(Assuming that you will not simply glue them to conic sections and still have them orbit in which case the rest of this post is purely academic) I would like to propose an alternative to still allow a true n-body simulation that would accumulate less error per time step. There is a case to be made by trying to keep the physics sim nbody for any future developments(TQFE, etc) and it just makes my physics bones happy. I also just learned about it in class tonight so Iâ€™m really excited about it.

Iâ€™m going to start from the beginning for those who donâ€™t write sims or have any knowledge about physics sims. Iâ€™m not sure what coord system the physics sim uses, but both cartesian and spherical coords will have large values of both radius and velocities at any given moment. This is the mentioned issue, and given a certain time step(say .001(1 millisecond)) you could still have significant error doing math on a velocity of say 22.2 km/s or 22200 m/s. This is not an unreasonable number for velocity and Iâ€™ve chosen this one because if we wanted an Earth like planet at 1 AU from a sunlike star, this is the orbital velocity. 100 miliseconds could give errors of 100 m/s per calculation so itâ€™s necessary to have smaller time steps so we donâ€™t lose accuracy. So there is a fundamental upperbound on the largest timestep without losing significant accuracy in the simulation which requires computational cycles and more importantly performance from the server.

What Iâ€™m proposing is a way that would still let us integrate along discrete time steps but with a larger time step, so that we can get the same accuracy with better performance or alternatively, more accuracy with the same amount of performance. This is where Iâ€™m unsure of the exact gains that could be made because Iâ€™m not really a CS person and I donâ€™t know whatâ€™s typical or how much this may improve it and why I wanted a discussion.

Basically we can integrate along the 6 orbital parameters that describe any orbit, but because their relative changes are much smaller we donâ€™t need as small as a time step.

Crash Course in orbital mech. An object in any orbit can be described by itâ€™s semi major axis(a), itâ€™s eccentricity(e), inclination(i), argument of periapsis(little omega), right ascension of the ascending node(big omega), and the Mean Anomaly(M). Itâ€™s possible to calculate the rate of change of each of these parameters due to a small perturbation(other bodies) and then describe the position and changes of position of an object in that manner. The relative changes of each of these will small because all of these are relatively static for anything in a stable orbit. So to repeat myself for the nth time it could be possible to have more accuracy within the nbody sim for planetary bodies with the same amount of performance is currently required by describing the orbits/positions of the bodies differently.

Of course, the devil is always in the details and this all depends on the fidelity of the inputs provided to the rate of change of the orbital parameters. At an initial glance it seems like itâ€™s feasible and Iâ€™d be interested in writing a simulation in matlab this weekend if someone more familiar with performance could help me write test profiles for it that could help give a definitive answer.

As always, if you have any questions about this let me know and Iâ€™d be happy to try and find an answer and feedback is welcome. As for one of my own, @InovaeFlavien or @INovaeKeith, do you think this is something that could be explored for something in the future? I know you guys are already swamped with other stuff to do related with actually *shipping* the product and this is a side project for unnecessary flavour but it would be really tasty flavour that helps set the infinity universe apart.