Skip to content

Commit

Permalink
robust looping
Browse files Browse the repository at this point in the history
  • Loading branch information
MenoData committed May 22, 2019
1 parent d913a8d commit 841dcdb
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ private static Moment calculateMeeus50(
sum += (c * Math.sin(Math.toRadians(arg)));
}

return JulianDay.ofEphemerisTime(jde + sum).toMoment();
return JulianDay.ofEphemerisTime(jde + sum).toMoment().with(Moment.PRECISION, TimeUnit.MINUTES);

}

Expand All @@ -719,18 +719,19 @@ private static Moment anomalistic(
) {

// first calculate an approximate anomalistic lunation which is rather too small
PlainDate date = after.toZonalTimestamp(ZonalOffset.UTC).toDate();
Moment ref = after.with(Moment.PRECISION, TimeUnit.MINUTES);
PlainDate date = ref.toZonalTimestamp(ZonalOffset.UTC).toDate();
double doy = date.getDayOfYear();
int lunation = (int) Math.floor((date.getYear() + (doy / date.lengthOfYear()) - 1999.97) * 13.2555);

Moment m = calculateMeeus50(lunation, apogee);

while (m.isBefore(after) || m.isSimultaneous(after)) {
while (!m.isAfter(ref)) {
lunation++;
m = calculateMeeus50(lunation, apogee);
}

return m.with(Moment.PRECISION, TimeUnit.MINUTES);
return m;

}

Expand Down

0 comments on commit 841dcdb

Please sign in to comment.