code: private static double sinAlt(
          double mjd0, // earliest moment of calendar date (usually midnight)
          double hour,
          double longitudeRad,
          double cosLatitude,
          double sinLatitude,
          double geodeticAngle,
          double refraction,
          double deltaT
      ) {
  
          double mjd = mjd0 + hour / 24.0; // UT
          double jct = toJulianCenturies(mjd + (deltaT / 86400));
          double[] data = MoonPosition.calculateMeeus(jct);
          double nutationCorr = data[0] * Math.cos(Math.toRadians(data[1])); // for apparent sidereal time
          double tau = AstroUtils.gmst(mjd) + Math.toRadians(nutationCorr) + longitudeRad - Math.toRadians(data[2]);
          double decl = Math.toRadians(data[3]);
  
          // transformation to horizontal coordinate system
          double sinAltitude = sinLatitude * Math.sin(decl) + cosLatitude * Math.cos(decl) * Math.cos(tau);
  
          // about impact of horizontal parallax on moon diameter see also Meeus (chapter 15)
          double correction = 0.7275 * getHorizontalParallax(data[4]) - refraction - geodeticAngle;
  
          // we search for the roots of this function
          return sinAltitude - Math.sin(Math.toRadians(correction));
  
      }
docs: sinus of moon altitude above or below horizon