private double obtainAccurateRiseSetTransit(double riseSetJD, final int INDEX, final int N_ITER, final boolean IS_SUN) {
        double step = -1;
        for (int i = 0; i < N_ITER; i++) {
            if (riseSetJD == -1) return riseSetJD; // -1 means no rise/set from that location
            setUTDate(riseSetJD);
            double out[] = IS_SUN ? doCalc(getSun()) : doCalc(getMoon());
            step = Math.abs(riseSetJD - out[INDEX]);
            riseSetJD = out[INDEX];
        }
        if (step > 1.0 / SECONDS_PER_DAY) return -1; // did not converge => without rise/set/transit in this date
        return riseSetJD;
    }
Calculates everything for the Sun and the Moon.
src/main/java/eu/hansolo/tilesfx/tools/SunMoonCalculator.java