getMoonPosition static method

Map<String, num> getMoonPosition(
  1. DateTime date,
  2. num lat,
  3. num lng
)

Implementation

static Map<String, num> getMoonPosition(DateTime date, num lat, num lng) {
  var lw = rad * -lng;
  var phi = rad * lat;
  var d = toDays(date);

  var c = moonCoords(d);
  var H = siderealTime(d, lw) - (c["ra"] ?? 0.0);
  var h = altitude(H, phi, (c["dec"] ?? 0.0));
  // formula 14.1 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998.
  var pa = math.atan2(
    math.sin(H),
    math.tan(phi) * math.cos(c["dec"] ?? 0.0) -
        math.sin(c["dec"] ?? 0.0) * math.cos(H),
  );

  h = h + astroRefraction(h); // altitude correction for refraction

  return {
    "azimuth": azimuth(H, phi, (c["dec"] ?? 0.0)),
    "altitude": h,
    "distance": c["dist"] ?? 0.0,
    "parallacticAngle": pa
  };
}