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.