Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting fixes and mean density in the System Editor #6058

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

zonkmachine
Copy link
Member

@zonkmachine zonkmachine commented Feb 8, 2025

Some fixes in physical descriptions.

  • Introducing a space before the unit. This was in response to the formatting of objects in the system overview but Format is called elsewhere. I have looked for possible issues in other modules but so far have found none. (Images)
  • Quick fix to use m³ instead of m3.
  • Add Mean Density to the System Editor. It's good to be able to quickly assess if the mass/volume ratio is within a reasonable
    range.

Before
exampleearth

Fixed
format


Some question marks.

  • Density should probably have its own format to aid in translation. I backed out of this part for now.
  • Mean density, as I first introduce it, is described in kg/m3. It looks like g/cm3 is the way to go for astronomical objects. This is how it's done now in the System editor. At least they should show the same. I'm looking into fixing this for the system overview too. This should possibly be done directly in CalcMeanDensity().

@zonkmachine
Copy link
Member Author

Fixed up gravitational acceleration. I'm not quite sure what changes would be needed in Format for a more permanent solution.

Copy link
Contributor

@fluffyfreak fluffyfreak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are good, I don't see any issues with the code 👍

@zonkmachine zonkmachine marked this pull request as ready for review February 15, 2025 14:16
@zonkmachine
Copy link
Member Author

I think these are good, I don't see any issues with the code 👍

Right, I agree. Still, parts of this should probably be fixed in Format but I haven't wrapped my head around it yet. It's not a new issue though and can be fixed up later.

@zonkmachine
Copy link
Member Author

I squashed it down to two commits.

@sturnclaw
Copy link
Member

Tons per cubic meter is (AFAIK) directly equivalent to grams per cubic centimeter; i.e. the number is the same regardless of the suffix (cm3 -> m3 is a 10^6 increase, as is grams -> tons). While the SI unit is technically more correct to use, I have no preference either way.

@zonkmachine
Copy link
Member Author

Tons per cubic meter is (AFAIK) directly equivalent to grams per cubic centimeter; i.e. the number is the same regardless of the suffix (cm3 -> m3 is a 10^6 increase, as is grams -> tons). While the SI unit is technically more correct to use, I have no preference either way.

I also have no preference. Right now it's t/m³ in the System Overview and g/cm³ in the System Editor. Maybe should settle for one of them? My guess is that t/m³ feels a bit more intuitive when you're dealing with something larger like a planet. At least it does to me.

{ name = lc.ESCAPE_VELOCITY, icon = icons.body_radius,
value = (not starport) and ui.Format.Speed(body.escapeVelocity , true) or nil },
{ name = lc.MEAN_DENSITY, icon = icons.body_radius,
value = (not starport) and ui.Format.Mass(body.meanDensity).."/m3" or nil },
value = (not starport) and ui.Format.Mass(body.meanDensity).."/" or nil },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sturnclaw I looked into changing the mean density to g/cm in this PR but I think this would need some work. Right now we're (I really as I'm the one responsible for the original addition) just using Format.Mass which is in tons and stick a /m³ to the end. To change this to g/cm we would need something like a new Format.Density to call. Also, instead of using Format.Mass, one could just use body.meanDensity and fix the format manually. Maybe I missed a way but I think adding a new Format.Density is the best way to do it.

Copy link
Member

@sturnclaw sturnclaw Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding Format.Density would be fine, as would changing the line to be ui.Format.Number(body.meanDensity, 3) .. lc.UNIT_DENSITY with UNIT_DENSITY being defined as the appropriate g/cm^3. Regardless of the tack taken, the unit suffix should ideally be a localized string for consistency (as unlikely as it is for SI units to be written differently in other languages...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. The SI unit for density (Wikipedia) is kg/m3 and that's what you get from calcMeanDensity. You need to divide with 1000 (like I did in the editor) so you get ui.Format.Number(body.meanDensity / 1000.0, 3)
I'll poke around some more with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants