• 0
ferrer

How is asteroid mass calculated?

Question

I recently attempted my first-ever asteroid redirect, with an A-class asteroid that was approaching Kerbin. Rendezvous was successful, but once I was attached to the asteroid, I realised that its mass was 150 tonnes - far more than my expected maximum of 10 tonnes. I found that this is a bug that was already on the tracker (Bug #9392) - it seems that all asteroids are spawning with a mass of 150 tonnes regardless of physical dimensions.

With little information available, I want to have a go at diagnosing the problem, and possibly at creating a mod to remedy it. My question is, how is the mass of an asteroid calculated? How is it dependent on class/size/shape, what algorithm is used to come up with it? I can see in the PotatoRoid part.cfg file that the default mass is 150 tonnes, so presumably something that used to happen on asteroid generation is no longer happening.

(As a secondary question, have many people noticed this bug before? I feel like if it was a widespread problem I would have found more threads about it.)

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 1

As far as I know, the asteroid mass is always calculated based on the density and a rough estimate of the asteroid volume*. I don't think the resource content is taken into account.

I have not (yet) seen the always-150-tons bug myself; in my tests asteroids always had generated-looking masses.

* I should add an extra comment based on the bug report linked from the OP: the asteroid mass is calculated when the asteroid first enters physics range. Unloaded asteroids will always mass 150 tons, because the asteroid's shape hasn't been generated yet. Hope this clarifies the "is it/isn't it a bug" questions.

Edited by Starstrider42
  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Another possible cause is something new overwriting the mass after the asteroid has been generated. Did they mention something about reloading assets while the game is running to speed up development and testing in dev notes before 1.1? Such a feature could do it.

As to how the mass is calculated, I would hazard a guess that they would calculate the volume of the asteroid and multiply it by a constant density. Throw in a random factor for ore content and you are all set. One could calculate the exact volume from the generated mesh, but since real asteroids are not all exactly the same density you would get away with estimating it from the average radius with the sphere volume formula. If you cannot access the average radius used to generate the mesh you may have to estimate that too. Averaging a few random vertices from the mesh should get you close enough.

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, monophonic said:

As to how the mass is calculated, I would hazard a guess that they would calculate the volume of the asteroid and multiply it by a constant density.

My own guess (based on no information whatsoever, other than that it's how I would code it if I were the one writing the feature) is that you've got it backwards, and that the mass isn't calculated, it's assigned.

In other words, an algorithm something like this:

  1. Oh, I need to generate a new random asteroid.
  2. Pick an asteroid class.
  3. For that asteroid class, randomly pick a mass, based on some allowed range that's configured somewhere.
  4. Having picked a mass, now generate a mesh for it, based on the physical size defined for that asteroid class, and maybe taking the mass into account as a scale multiplier.

Of course, that doesn't explain how you could get a Class A asteroid with a mass of 150 tons.  That sounds like a bug to me.  Have you reported it?

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I would ask @Starstrider42, the author of the lovely CustomAsteroids mod.  If anybody knows how baby asteroids are made, it's him.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I'm encountering the same issue, and I was going to report it, but I wasn't sure where you go now to report bugs.

I can add something to this, it did NOT effect my Emiko Station Asteroid!  I just went and rechecked and that one is still weighing in at well over 3,000t. But when I checked a couple newly discovered dres-deroids, no matter what the class, they weighed in at 150t.  So this makes me think it's only happening to newly spawned asteroids.

Edited by Just Jim

Share this post


Link to post
Share on other sites
  • 0
8 hours ago, monophonic said:

As to how the mass is calculated, I would hazard a guess that they would calculate the volume of the asteroid and multiply it by a constant density. Throw in a random factor for ore content and you are all set. One could calculate the exact volume from the generated mesh, but since real asteroids are not all exactly the same density you would get away with estimating it from the average radius with the sphere volume formula. If you cannot access the average radius used to generate the mesh you may have to estimate that too. Averaging a few random vertices from the mesh should get you close enough.

37 minutes ago, Snark said:

My own guess (based on no information whatsoever, other than that it's how I would code it if I were the one writing the feature) is that you've got it backwards, and that the mass isn't calculated, it's assigned.

Though I initially thought that it would be assigned, I did see the following lines in the config file:

Quote

MODULE
{
    name = ModuleAsteroid    
    density = 0.03
}

That might indicate that an actual calculation takes place, but I'm not an expert so I don't know how/whether that's used.

41 minutes ago, Snark said:

That sounds like a bug to me.  Have you reported it?

It's already on the tracker (linked in the OP). My experiences match exactly those described in the bug report (all asteroids of all classes spawn with mass 150t), so I didn't have any information to add.

Share this post


Link to post
Share on other sites
  • 0

Nope it's not a bug.. it's a feature !!

Look in the folder:- GameData\Squad\Parts\Misc\PotatoRoid

You'll find only one asteroid 'part' file.. and it's mass is set to 150 tons

...

// --- standard part parameters ---
mass = 150
dragModelType = default

...

Share this post


Link to post
Share on other sites
  • 0
11 minutes ago, ColKlonk said:

Nope it's not a bug.. it's a feature !!

Look in the folder:- GameData\Squad\Parts\Misc\PotatoRoid

You'll find only one asteroid 'part' file.. and it's mass is set to 150 tons

...

// --- standard part parameters ---
mass = 150
dragModelType = default

...

ok, but I have an installation of 0.90 and the parameter is the same, but the asteroids appeared in various sizes and masses, not now

Share this post


Link to post
Share on other sites
  • 0
23 minutes ago, ColKlonk said:

Nope it's not a bug.. it's a feature !!

Look in the folder:- GameData\Squad\Parts\Misc\PotatoRoid

You'll find only one asteroid 'part' file.. and it's mass is set to 150 tons

...

// --- standard part parameters ---
mass = 150
dragModelType = default

...

That's what I was referencing in my original post. It definitely is a bug, asteroids have previously always generated with different masses.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now