1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

# Does the Source on github actually contain the planets release?

Discussion in 'Source Code' started by westeastnorth, Nov 18, 2015.

1. ### westeastnorth

Joined:
Oct 13, 2015
Messages:
15
Trophy Points:
12
Looking into it the source code on a very preliminary basis, I do not seem to find any information about how gravity is calculated for planets over distance, atmosphere density vs ion vs atmos thruster and etc.

While it is possible to figure out this information, I'm still curious about the direct mechanics and equations.

• Agree x 1
2. ### Seamus Donohue

Joined:
Oct 3, 2014
Messages:
79
Trophy Points:
57
The closest I could find is at https://github.com/KeenSoftwareHous...e/Game/GameSystems/MyGravityProviderSystem.cs

Code:
```public static Vector3 CalculateNaturalGravityInPoint(Vector3D worldPoint, bool clearVectors = true)
{
return Vector3.Zero;
}

public static float CalculateHighestNaturalGravityMultiplierInPoint(Vector3D worldPoint)
{
return 0;
}```
Based on personal experience in Singleplayer, I'm pretty sure those returns aren't always zero.

3. ### Digi

Joined:
Nov 13, 2013
Messages:
2,090
Trophy Points:
237
It doesn't seem to be updated as Sandbox.Game.Entities.MyPlanet does not exist. I'm using that class in a mod and I know for sure exists in the game.

You could use ILSpy on the game's dlls to see the mechanics, you could start from the class I mentioned.

4. ### Seamus Donohue

Joined:
Oct 3, 2014
Messages:
79
Trophy Points:
57
In other news, I've figured out Space Engineers natural gravity through empirical experimentation.

First, I figured out the center of the Earth-like planet by using a Programmable Block and a Remote Control to (1) record the position of the Remote Control and (2) record the direction of gravity. By triangulating multiple measurements, I got measured results for the center of the Earth-like planet's gravity.

Code:
```Calculations of Earth's Center by gravity triangulator program.
GPS:center:0.4994941:0.5111076:0.499977:
GPS:center:0.4990736:0.5034607:0.5005552:
GPS:center:0.5001641:0.5007017:0.4976434:```
I proceeded on the assumption that the center is located at (0.5,0.5,0.5).

I then took additional observations are various altitudes to get gravitational acceleration versus distance from center. Showing only points where the gravity isn't zero:
Code:
```Distance	Gravity
(meters)	(m/s^2)
102786.457	0.5008442248
101936.8636	0.5308050511
100952.5493	0.5681106175
99957.29988	0.6089089105
98974.38133	0.6525207896
97929.71888	0.7028333219
96932.00045	0.7550639083
95963.55998	0.8100455877
94951.41531	0.8724565959
93940.7883	0.9403176155
92975.63484	1.010810754
91967.6616	1.090957758
90939.36725	1.180294592
89954.74875	1.273753121
88985.15292	1.374140368
87971.12817	1.488924813
86952.70166	1.61537135
85973.99325	1.748574948
84977.07326	1.897324192
84309.1594	2.005074926
84021.03481	2.053703648
82989.75254	2.239147182
81965.16332	2.442579872
80722.60082	2.718241031
80028.72635	2.887570374
78996.02519	3.162403088
77907.70147	3.484906837
77008.55342	3.779907456
75903.16082	4.182490066
74907.67467	4.587433114
73919.86881	5.034143956
72945.67089	5.524046584
71910.87561	6.105087627
70889.66077	6.747977973
69485.42367	7.762434534
68986.45242	8.164079306
67910.00925	9.114175904
66945.35418	9.81000101
65982.55768	9.810001027
64988.25036	9.810000094
63966.66504	9.810000906
62992.94152	9.810001379
61983.99366	9.810000914```
Poking at the numbers in a spreadsheet, I discovered that above 67000 meters, this fits a simple formula of:

Gravity = Constant / ( Distance ^ 7 )
(Distance in meters, Gravity in m/s^2)

For the Earth-like, this constant is 6.07091 * 10^34.

...

For the Moon-like, I triangulated the center as GPS:Moon Center:16384.5:136384.5:-113615.5:
Code:
```Distance	Gravity
12284.65305	0.4988782561
12230.26781	0.514615717
12173.31007	0.5317090431
12103.32525	0.5536074221
12022.27053	0.5802690043
11903.00462	0.6222123291
11745.97428	0.6828283423
11575.89537	0.7562278979
11437.63075	0.8225879386
11301.52535	0.8944899118
11119.44796	1.002195052
10861.61442	1.181066042
10685.53435	1.32422308
10505.61334	1.491368655
10344.50768	1.661751356
10134.29614	1.918578922
9950.689574	2.180532628
9830.199772	2.374643642
9754.343719	2.452500115
9649.170218	2.452500132
9556.911519	2.452499876```
Again, for altitudes above 9800 meters,

Gravity = Constant / ( Distance ^ 7 )
(Distance in meters, Gravity in m/s^2)

For the Moon-like, this constant is 2.10637 * 10^28.

• Like x 1
5. ### westeastnorth

Joined:
Oct 13, 2015
Messages:
15
Trophy Points:
12
Those are very curious numbers, compared against my measurements it would seem the surface or "sea-level" of the Earth-like planet is in fact ~1 km off.

As I'm mostly interested in how Planetary influence works with Ion Thrusters and Atmos Thrusters. I am aware that at minimum they are 30% effective but being able to simply plug in equations for max operating ceilings for atmos thrusters and min operating ceilings for ion would be useful along with oxygen density. The atmos thruster effectiveness has an apparently linear falloff, along with ion thrusters except they're inverse.

Atmos thrusters work entirely on planetary influence and atmosphere thickness, this is why an atmosphere thruster will not work in a pressurized hanger in 'outer space' free from the influence of a planet.

6. ### JoeTheDestroyer

Joined:
Feb 5, 2015
Messages:
572
Trophy Points:
137
There was some discussion on this here.

Gravity uses the following formula:
a_g(r)=
( 9.81 * G )*( R*(1+H)/r )^7 if r>R*(1+H)
( 9.81 * G ) if R <= r <= R*(1+H)
( 9.81 * G )*( 1 - r/R ) if r < R
Where G is the surface gravity, R is the base radius of the planet ("surface") and H is a coefficient related to the height of the highest hill/mountain.

Ion thrusters vary linearly between:
30% @ r=R
100% @ r=R*(1 + H*A) (r=R+14.4km for earth-like)
Where A is a factor describing the height of the "atmosphere" w.r.t. hill height.

Atmospheric thrusters vary linearly between:
100% @ r=R
0% @ r=R*(1 + (1-0.3)*H*A) (r=R+10.08km for earth-like)

These factors are defined in "PlanetGeneratorDefinitions.sbc":
G as "SurfaceGravity". (1.0 for earth-like)
H as "HillParams","Max". (0.12 for earth-like)
A as "LimitAltitude". (2.0 for earth-like)

And R is 60000 for earth-like.

• Informative x 2
• Like x 1
7. ### westeastnorth

Joined:
Oct 13, 2015
Messages:
15
Trophy Points:
12
Oh Thanks JoeTheDestroyer, i'll try to post all of this up to wiki so people won't have to keep asking >.<

But yes, i'm guessing this means the source code up on github doesn't have planets then? which is really odd, since I heard people kept on being able to simply download it and playtest planets via simply compiling it. Hopefully, keen eventually starts updating it again.

Thanks again guys.

8. ### leftler

Joined:
Feb 9, 2015
Messages:
76
Trophy Points:
27
No people have not been able to playtest planets, people have tried to do that and often come here complaining when it does not work. The only planets thing that was in the source code is their very first stages, but the final result is nothing like what was there.

People who said they downloaded the source to test planets are either lying or did not understand that keen was not publishing the planets source code till after the release (which as of this post they still have not done) and was actually testing keen's first experiments.

• Agree x 2
9. ### JoeTheDestroyer

Joined:
Feb 5, 2015
Messages:
572
Trophy Points:
137
An older version on github has some of the early planet code, which people built and played around with. In my own conspiracy-addled mind, this stealing of their thunder is what led to Keen stopping updates (and pull request acceptance). The only update since then removed most planet related code.

We're hoping that with planets out now, they will have time (and inclination) to start keeping github updated again. But it's only been a week and we have other toys to play with, so I'm not in a big hurry on that...

• Agree x 2
10. ### westeastnorth

Joined:
Oct 13, 2015
Messages:
15
Trophy Points:
12
Plugging in the formulas you provided it seems that pretty much everything that makes a planet, a planet has its own special properties that do not intermix with each other too much, most notably o2 pressurization is not the same as atmosphere thickness nor does it seem to be a function of oxygen density.

I noticed a pattern during my testing that every 4km from about 58400 r or 1600 m below the "surface" of Earthlike. The oxygen pressure should be 100% and then linearly at ~62400 the pressure drops to 75% or 3 bar on the air vent. Then again at 66400 m to 2 bar (50%), 1 bar at 70400 m (25%) and none at 74400 m (0%) where the atmosphere should rightly end. Working backwards it seems the oxygen pressurization begins under the radius, i'm not sure what to make of the 0.9 oxygen density in the sbc file it does not seem to fit in anywhere.

Edit: a relationship of o2 density and atmosphere does seem to exist, after modding Earthlike to 1.0 o2 density the numbers are as predicted and transition where they should.

Last edited: Nov 19, 2015
• Informative x 1