getMoonIllumination static method
Implementation
static Map<String, num> getMoonIllumination(DateTime date) {
var d = toDays(date);
var s = sunCoords(d);
var m = moonCoords(d);
var sdist = 149598000; // distance from Earth to Sun in km
var phi = math.acos(math.sin(s["dec"] ?? 0.0) * math.sin(m["dec"] ?? 0.0) +
math.cos(s["dec"] ?? 0.0) *
math.cos(m["dec"] ?? 0.0) *
math.cos((s["ra"] ?? 0) - (m["ra"] ?? 0.0)));
var inc = math.atan2(
sdist * math.sin(phi), (m["dist"] ?? 0.0) - sdist * math.cos(phi));
var angle = math.atan2(
math.cos(s["dec"] ?? 0.0) *
math.sin((s["ra"] ?? 0.0) - (m["ra"] ?? 0.0)),
math.sin(s["dec"] ?? 0.0) * math.cos(m["dec"] ?? 0.0) -
math.cos(s["dec"] ?? 0.0) *
math.sin(m["dec"] ?? 0.0) *
math.cos((s["ra"] ?? 0.0) - (m["ra"] ?? 0.0)));
return {
"fraction": (1 + math.cos(inc)) / 2,
"phase": 0.5 + 0.5 * inc * (angle < 0 ? -1 : 1) / pi,
"angle": angle
};
}