Star density calculation = weird result.

Click For Summary
SUMMARY

The forum discussion centers on the calculation of star density in a fictional galaxy generation for an indie game. The developer encountered an issue where the calculated density values were excessively high, resulting in values around 10 digits. The problem was traced back to using Sol's radius in kilometers instead of meters, leading to incorrect density units of kg/km³ instead of the desired kg/m³. The correct density should be calculated in g/cm³ for accurate results.

PREREQUISITES
  • Understanding of astrophysics concepts, particularly stellar types and properties.
  • Familiarity with mathematical calculations involving volume and density.
  • Knowledge of unit conversions, specifically between kilometers, meters, and grams.
  • Experience with game development, particularly in procedural generation techniques.
NEXT STEPS
  • Research the formula for calculating the volume of a sphere and its application in astrophysics.
  • Learn about unit conversions in scientific calculations, focusing on density measurements.
  • Explore best practices for procedural generation in game development, particularly for astronomical objects.
  • Investigate common pitfalls in numerical calculations in programming, especially regarding data types and units.
USEFUL FOR

This discussion is beneficial for indie game developers, astrophysics enthusiasts, and anyone involved in procedural generation of celestial bodies, particularly those interested in accurate astronomical calculations.

Adyaphede
Messages
3
Reaction score
0
Hello everyone!

I'm new here and I've checked this forums once in a while for physics information, mainly astrophysics stuff but I usually found all the answers I needed. Not this time though.

A bit about me.
I'm an Indie game developer and the game I'm working on takes place in a fictional galaxy generated from scratch. The scale of that galaxy goes from tiny to 1% realist (or about 1 billion stars) some would argue this scale would be .5%.

Galaxy generation can yield 3 types of galaxies: spiral, barred or elliptical.

Based on the stellar types and some generalization based on those types, all stars are generated and placed according to the type of galaxy.

Each star has its own properties set like mass, radius, etc based on its type. I take each type's upper and lower limits from the Stellar Type's page on wikipedia for each attribute and randomize from lower to upper limit.

My problem is the density I am getting for a given type in relation to Sol.

Each star, when selected, gives a report of sort, informing the player of the star's attributes in Sol.

So for example you could get for an M class star: "Radius: 0.67 Sol"

To come up with the star's density, I come up with its radius multiplied by sol's radius (because the types' limits are in Sol, so I have to mult it by Sol to get the star's real radius).

Then I get the star's mass using the same as above mult by Sol's mass.

The star's volume comes next and this is derived from the star's radius (4/3 * PI * radius^3).

Last, to get the density, it's mass / volume.

That's the contention point. I always get an awful number (usually around 10 digits) after being divided by Sol's density. This can't be right.

Might as well put a screenshot so it's easier to see/understand.

[PLAIN]http://www.danyrioux.com/files/weird_density.png
In the picture above, the star's attributes were:
Star Mass : 3.5223205E30
Star Volume : 4.14757254E18
Star Density : 8.4924871E11

Since Sol's density is 1.408E3, I understand the huge result and that it's wrong (obviously), but what I don't understand is why.

Any help would be appreciated. If you need more information I'll gladly reply asap.
 
Last edited by a moderator:
Astronomy news on Phys.org
My guess is that when you are multiplying by Sol's radius, you are using the value in kilometers rather than in meters, This gives you an answer of kg/km^3 rather than what you want which is kg/m^3.
 
That was exactly it Janus.

In fact, the answer I needed was in g/cm3 but was getting the information in kg/km3 as you said. It took a while but found it.

Thanks. :)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 0 ·
Replies
0
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 26 ·
Replies
26
Views
6K
  • · Replies 49 ·
2
Replies
49
Views
6K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 48 ·
2
Replies
48
Views
6K