astro.Function.bodyMass - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / astro / bodyMass

Function: bodyMass()

bodyMass(body): number | null

Defined in: src/astro/body-physics.ts:104

A body's mass in kilograms, whichever unit the scan wrote it in.

Parameters

body

BodyProperties

The body. A planet or moon carries MassEM (Earth masses), a star StellarMass (solar masses).

Returns

number | null

The mass in kilograms, or null when the scan wrote neither field usably. When a record carries both — which no journal line does — MassEM is the one read.

Throws

If body is not an object.

Example

import { bodyMass } from '@elite-dangerous-almanac/core/astro/body-physics';

bodyMass({ MassEM: 1 }); // -> 5.972e24
bodyMass({ StellarMass: 1 }); // -> 1.989e30
bodyMass({ Radius: 6_371_000 }); // -> null
⚠️ **GitHub.com Fallback** ⚠️