grahan — the open-source sky engine
    Preparing search index...

    Function nextCrossing

    • First instant at or after jdUtStart when value reaches targetDegrees.

      value must be increasing (mod 360) with a rate that stays within roughly ±25% of meanRatePerDay: the fixed-point iteration corrects at the mean rate, so each step shrinks the error geometrically. Converges to well under a second.

      Parameters

      • value: (jdUt: number) => number

        angle in degrees as a function of UT Julian day

      • meanRatePerDay: number

        mean rate of value, degrees per day

      • targetDegrees: number

        the angle to reach, degrees

      • jdUtStart: number

        search start, UT Julian day

      Returns number

      // First quarter moon after J2000: elongation reaches 90°.
      nextCrossing(
      (jd) => normalizeDegrees(
      moonPosition(jd).apparentLongitude - sunPosition(jd).apparentLongitude,
      ),
      360 / 29.530588861,
      90,
      2451545,
      ); // ≈ 2451558.1 (2000-01-14 13:34 UT)