orbitalPeriod static method
Calculates the orbital period of a body around a central mass using Kepler's third law.
T = 2π * sqrt(a³ / GM)
semiMajorAxis
: The semi-major axis of the orbit.centralMass
: The mass of the central body being orbited.
Returns the orbital period as a Time quantity in seconds. Throws ArgumentError if the central mass or semi-major axis is zero.
Implementation
static Time orbitalPeriod(Length semiMajorAxis, Mass centralMass) {
if (centralMass.value <= 0 || semiMajorAxis.value <= 0) {
throw ArgumentError('Central mass and semi-major axis must be positive.');
}
final a3 = math.pow(semiMajorAxis.inM, 3);
final gm = PhysicalConstants.gravitationalConstant * centralMass.inKilograms;
final seconds = 2 * math.pi * math.sqrt(a3 / gm);
return Time(seconds, TimeUnit.second);
}