lunarPoint function

EclipticPosition lunarPoint(
  1. Ephemeris ephemeris,
  2. LunarPoint point,
  3. double jdTT
)

Position of point on the true ecliptic and equinox of date at jdTT.

Mean points come from formulas (they do not use ephemeris); osculating ones from the Moon's position and velocity. The distance in the result is 0 for mean points and for the node; for the osculating apogee it is the apogee distance of the instantaneous orbit.

Implementation

EclipticPosition lunarPoint(
  Ephemeris ephemeris,
  LunarPoint point,
  double jdTT,
) {
  final t = centuriesSinceJ2000(jdTT);
  final dpsi = nutation(t).longitude;
  switch (point) {
    case LunarPoint.meanNode:
      return EclipticPosition(_degrees(_meanNode(t) + dpsi), 0, 0);
    case LunarPoint.meanApogee:
      // Długość perygeum Π to kąt „łamany”: po ekliptyce do węzła, dalej
      // po orbicie. Apogeum leży naprzeciw, na orbicie nachylonej
      // o [meanLunarInclination], więc jego długość ekliptyczna to rzut
      // na ekliptykę.
      final node = _meanNode(t);
      final fromNode = _meanPerigee(t) + math.pi - node;
      const i = meanLunarInclination * math.pi / 180;
      final lon =
          node +
          math.atan2(math.sin(fromNode) * math.cos(i), math.cos(fromNode));
      return EclipticPosition(
        _degrees(lon + dpsi),
        math.asin(math.sin(fromNode) * math.sin(i)) * 180 / math.pi,
        0,
      );
    case LunarPoint.trueNode:
    case LunarPoint.osculatingApogee:
      return _osculating(ephemeris, point, jdTT, t, dpsi);
  }
}