View Source SpaceDust.Bodies.Moon (Space Dust v0.3.0)
Lunar body parameters and position calculations.
Provides functions to compute the Moon's position in various coordinate frames, including ECI (Earth-Centered Inertial).
The algorithms are based on the low-precision lunar coordinates from the Astronomical Almanac (approximate accuracy ~0.3 degrees in longitude, ~0.2 degrees in latitude, ~0.003 Earth radii in distance).
Summary
Functions
Calculate the Moon's apparent right ascension and declination.
Calculate the Moon's unit vector from Earth in ECI frame.
Calculate the distance from Earth to the Moon in meters.
Calculate the Moon's position in the Earth-Centered Inertial (ECI) frame.
Calculate the Moon's position in ECI frame using a UTC struct.
Mean Earth-Moon distance in meters
Moon's gravitational parameter in m^3/s^2
Calculate the Moon's phase angle (angle between Sun and Moon as seen from Earth).
Lunar radius in meters
Functions
@spec apparent_position(DateTime.t()) :: {float(), float()}
Calculate the Moon's apparent right ascension and declination.
Parameters
epochUtc- DateTime in UTC
Returns
{right_ascension, declination}- tuple of angles in radians
@spec direction(DateTime.t()) :: SpaceDust.Math.Vector.vector()
Calculate the Moon's unit vector from Earth in ECI frame.
Parameters
epochUtc- DateTime in UTC
Returns
%Vector3D{}- Unit vector pointing from Earth to Moon
@spec distance(DateTime.t()) :: float()
Calculate the distance from Earth to the Moon in meters.
Parameters
epochUtc- DateTime in UTC
Returns
- Distance in meters
@spec eci_position(DateTime.t()) :: SpaceDust.Math.Vector.vector()
Calculate the Moon's position in the Earth-Centered Inertial (ECI) frame.
Uses the low-precision lunar coordinates from the Astronomical Almanac. Position is returned in meters.
Parameters
epochUtc- DateTime in UTC
Returns
%Vector3D{}- Moon position in ECI frame (meters)
Example
iex> SpaceDust.Bodies.Moon.eci_position(~U[2024-01-01 12:00:00Z])
@spec eci_position_utc(SpaceDust.Time.UTC.t()) :: SpaceDust.Math.Vector.vector()
Calculate the Moon's position in ECI frame using a UTC struct.
Parameters
utc-%SpaceDust.Time.UTC{}struct
Returns
%Vector3D{}- Moon position in ECI frame (meters)
Mean Earth-Moon distance in meters
Moon's gravitational parameter in m^3/s^2
@spec phase_angle(DateTime.t()) :: float()
Calculate the Moon's phase angle (angle between Sun and Moon as seen from Earth).
Parameters
epochUtc- DateTime in UTC
Returns
- Phase angle in radians (0 = new moon, π = full moon)
Lunar radius in meters