getSolarAzimuth method

double getSolarAzimuth (
  1. DateTime dateTime,
  2. double lat,
  3. double lon
)

Return the Solar Azimuth for the horizontal coordinate system at the given location at the given time. Not corrected for altitude. True south is 0 degrees.

@param cal time of calculation @param lat latitude of location for calculation @param lon longitude of location for calculation @return FIXME

Implementation

static double getSolarAzimuth(DateTime dateTime, double lat, double lon) {
  double julianDay = _getJulianDay(dateTime);
  double julianCenturies = _getJulianCenturiesFromJulianDay(julianDay);

  double eot = _getEquationOfTime(julianCenturies);

  double longitude =
      (dateTime.hour + 12.0) + (dateTime.minute + eot + dateTime.second / 60.0) / 60.0;

  longitude = -(longitude * 360.0 / 24.0) % 360.0;
  double hourAngleRad = radians(lon - longitude);
  double declination = _getSunDeclination(julianCenturies);
  double decRad = radians(declination);
  double latRad = radians(lat);

  return degrees(atan(sin(hourAngleRad) /
          ((cos(hourAngleRad) * sin(latRad)) - (tan(decRad) * cos(latRad))))) +
      180;
}