public static GCHourTime CalcSunrise(GregorianDateTime vct, GCEarthData earth) { double tempSunrise = 180.0; GCSunData sun = new GCSunData(); for (int i = 0; i < 3; i++) { sun.SunPosition(vct, earth, tempSunrise - 180.0); double x; // definition of event double eventdef = 0.01454; /* switch(ed.obs) * { * case 1: // civil twilight * eventdef = 0.10453; * break; * case 2: // nautical twilight * eventdef = 0.20791; * break; * case 3: // astronomical twilight * eventdef = 0.30902; * break; * default:// center of the sun on the horizont * eventdef = 0.01454; * break; * }*/ eventdef = (eventdef / GCMath.cosDeg(earth.latitudeDeg)) / GCMath.cosDeg(sun.declinationDeg); x = GCMath.tanDeg(earth.latitudeDeg) * GCMath.tanDeg(sun.declinationDeg) + eventdef; if ((x >= -1.0) && (x <= 1.0)) { // time of sunrise tempSunrise = 90.0 - earth.longitudeDeg - GCMath.arcSinDeg(x) + sun.equationOfTime; } else { // initial values for the case // that no rise no set for that day tempSunrise = -360.0; break; } } GCHourTime result = new GCHourTime(); result.longitude = sun.longitudeDeg; result.SetDegTime(tempSunrise + earth.OffsetUtcHours * 15.0); return(result); }
public static GCHourTime CalcSunset(GregorianDateTime vct, GCEarthData earth) { double tempSunset = 180.0; GCSunData sun = new GCSunData(); for (int i = 0; i < 3; i++) { sun.SunPosition(vct, earth, tempSunset - 180.0); double x; // definition of event double eventdef = GCSunData.RiseAngleLevel; eventdef = (eventdef / GCMath.cosDeg(earth.latitudeDeg)) / GCMath.cosDeg(sun.declinationDeg); x = GCMath.tanDeg(earth.latitudeDeg) * GCMath.tanDeg(sun.declinationDeg) + eventdef; if ((x >= -1.0) && (x <= 1.0)) { // time of sunset tempSunset = 270.0 - earth.longitudeDeg + GCMath.arcSinDeg(x) + sun.equationOfTime; } else { // initial values for the case // that no rise no set for that day tempSunset = -360.0; break; } } GCHourTime result = new GCHourTime(); result.longitude = sun.longitudeDeg; result.SetDegTime(tempSunset + earth.OffsetUtcHours * 15.0); return(result); }