Answers for "My orbits don't look like KSP"
http://answers.unity.com/questions/1705535/my-orbits-dont-look-like-ksp.html
The latest answers for the question "My orbits don't look like KSP"Answer by Bunny83
http://answers.unity.com/answers/1705561/view.html
Well, there are several things you have to clear up first. First of all do not base your knowledge of orbits on other games. Second your whole equation doesn't seem to make much sense and does not look like it resembles Newtonian gravity, at all. All your "surface" references doesn't make much sense and you scale your gravity linearly by the distance. Actual gravity scales with the quare of the distance.
<br>
The actual gravitational force is
F = G * m1 * m2 / dist²
However the resulting acceleration for a body is `a = F / m`. That's why the attacted mass is irrelevant for the acceleration. If you plugin the values
F_body = G * m_center * m_body / dist²
a_body = F_body / m_body
a_body = G * m_center * m_body / (dist² * m_body) //-->
a_body = G * m_center / dist²
As you can see the mass of the body doesn't matter as it cancels out. In the case of an object close to earth, m_center is the mass of the earth and "dist" is the distance from the **earth center**. On the surface that's about 6000 km and gives us our famous acceleration of 9.81 m/s². However further out that value is significantly less. Keep in mind that the acceleration scales by the square of the distance from the center. So at double the radius it will be only a quater.
<br>
Yes, on the surface or very close to the surface the acceleration doesn't really change much. Most things we care about on earth happens within say a 12km range above ground If we take the average earth radius (6371 km) and plug it into the formula we get 9.8196 m/s². If we add 12km we get an acceleration of about 9.7827 m/s². So only a tiny difference (0.037m/s² less)
<br>
Of course on a planetary scale distances get much larger therefore you really should use the distance squared properly.
<br>
However the fact that you see an eliptical orbit that is in itself rotating around the sun / center is just a matter of fact that you're doing a time discrete integration simulation. This will never give you an accurate result. The real world does not run in discrete time steps but performs actual continous integration. Increasing the simulation steps per second would help to mitigate the issue slightly but your orbit will always drift when doing this. Many orbit simulations work with the derived orbit equations where you define your orbit based on the initial condition / changes and if no external force is applied we just follow our calculated orbit.
<br>
While calculating such an orbit is not rocket science, it is actually part of it and naturally not that easy ^^. Here are a few sources which might help you out
- [https://en.wikipedia.org/wiki/Orbit][1]
- [https://en.wikipedia.org/wiki/Kepler_orbit][2]
- [https://en.wikipedia.org/wiki/Orbital_elements#Keplerian][3]
The real question is what do you want this orbit for and what level of accuracy do you aim for?- Note that even when using the right forumlas due to floating point errors a simulation won't be "100% correct". When it comes to actual orbits there are so many things that has to be accounted for. While still in the athmosphere there's drag / air resistance. All objects in a orbital system rotate around the [center of mass][4], even the largest "center" object. If more objects are involved this gets infinitely complex. Those changes are tiny but still have a small effect, especially over time. So again it highly depends on what your goals are.
<br>
Games in general do not really need to be physical accurate. In fact PhysX (which is used by the Unity engine) is in itself not physically correct. It's just a simulation that is fast and very close to common needs where the errors are usually small enough so you won't notice. For example PhysX does not perserve the angular momentum as it true in actual physics. Instead it will just preserve the angular velocity. This makes the simulation much simpler but certain things are impossible to simulate with such a system. Like the [tumbling effect][5] mentioned here in the middle bottom figure. Because this never happens in Unity we can not use this physics system to simulate things like a [kickflip][6] of a skateboard properly without a massive amount of workarounds. Most physics systems for games are build to give you a good approximation and to be efficient.
[1]: https://en.wikipedia.org/wiki/Orbit
[2]: https://en.wikipedia.org/wiki/Kepler_orbit
[3]: https://en.wikipedia.org/wiki/Orbital_elements#Keplerian
[4]: https://en.wikipedia.org/wiki/File:Orbit2.gif
[5]: https://www.youtube.com/watch?v=fZYfX9VvN8M&t=80s
[6]: https://www.youtube.com/watch?v=wfCgCXvw50ASat, 07 Mar 2020 14:08:11 GMTBunny83