/******************************************************************************* * NAME: * AppSolarCoordinates * * PURPOSE: * Computes the apparent coordinates of the sun * * REFERENCES; * Meeus, Jean. "Astronomical Algorithms, 1st ed." Willmann-Bell. Inc. 1991. * pp. 151-153 * * INPUT ARGUMENTS: * JD (double) * Julian Day for day/time to calculate at TD * * OUTPUT ARGUMENTS: * *alpha (double) * apparent right ascention in degrees * *delta (double) * apparent declination in degrees * * RETURNED VALUE: * none yet * * GLOBALS USED: * none * * FUNCTIONS CALLED: * SinD, CosD, Revolution, atan2 * * DATE/PROGRAMMER/NOTE: * 09-16-1999 Todd A. Guillory created * 07-04-2000 Todd A. Guillory condensed equations some more * 07-27-2000 Todd A. Guillory checked with example 24.a * ********************************************************************************/ void app_solar_coordinates( double JD, double *alpha, double *delta) { double T, /* Julian Centuries */ L0, /* geometric mean longitude of the sun */ M, /* mean anomoly */ e, /* eccentricity of Earth's orbit */ C, /* Sun's equation of center */ Long, /* true longitude of the sun */ v, /* true anomaly of the sun */ R, /* Radius in AU */ omega, /* nutation */ lamda, /* apparent longitude of the sun */ ep0; /* mean obliquity of the ecliptic */ /* Get Julian Centuries */ T = julian_centuries(JD); /* calculate the geometric mean longitude of the sun */ L0 = 280.46645 + 36000.76983 * T + 0.0003032 * T * T; /* calculate the mean anomaly of the sun */ M = 357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048 * T * T * T; /* calculate the eccentricity of the Earth's Orbit */ e = 0.016708617 - 0.000042037 * T - 0.0000001236 * T * T; /* calculate the sun's equation of center */ C = (1.914600 - 0.004817 * T - 0.000014 * T * T) * SinD(M) + (0.019993 - 0.000101 * T) * SinD(2*M) + 0.000290 * SinD(3*M); /* calculate the sun's true longitude */ Long = L0 + C; /* calculate the true anomaly */ v = M + C; /* calculate the sun's radius vector, distance of the earth in AUs */ R = (1.000001018 * ( 1 - e * e)) / ( 1 + e * CosD(v) ); omega = 125.04 - 1934.136 * T; /* calculate the apparent longitude of the sun */ lamda = Revolution(Long - 0.00569 - 0.00478 * SinD(omega)); /* calculate the mean obliquity of the ecliptic */ ep0 = ((23*60)+26)*60+21.448 - 46.8150 * T - 0.00059 * T * T + 0.001813 * T * T * T; ep0 /= 3600; /* correct mean obliquity of the ecliptic */ ep0 = ep0 + 0.00256 * CosD(omega); /* calculate right ascension and declination */ *alpha = Revolution(atan2(CosD(ep0) * SinD(lamda), CosD(lamda)) * kRadDeg); *delta = asin(SinD(ep0) * SinD(lamda)) * kRadDeg; }
double SunTimes::GMST0(double d) { double sidtim0; sidtim0 = Revolution((180.0 + 356.0470 + 282.9404) + (0.9856002585 + 4.70935E-5) * d); return sidtim0; }
void SunTimes::Sunpos(double d, double &lon, double &r) { double M,//太阳的平均近点角,从太阳观察到的地球(=从地球看到太阳的)距近日点(近地点)的角度。 w, //近日点的平均黄道经度。 e, //地球椭圆公转轨道离心率。 E, //太阳的偏近点角。计算公式见下面。 x, y, v; //真近点角,太阳在任意时刻的真实近点角。 M = Revolution(356.0470 + 0.9856002585 * d);//自变量的组成:2000.0时刻太阳黄经为356.0470度,此后每天约推进一度(360度/365天 w = 282.9404 + 4.70935E-5 * d;//近日点的平均黄经。 e = 0.016709 - 1.151E-9 * d;//地球公转椭圆轨道离心率的时间演化。以上公式和黄赤交角公式一样,不必深究。 E = M + e * Radge * Sind(M) * (1.0 + e * Cosd(M)); x = Cosd(E) - e; y = sqrt(1.0 - e * e) * Sind(E); r = sqrt(x * x + y * y); v = Atan2d(y, x); lon = v + w; if (lon >= 360.0) lon -= 360.0; }
int SunTimes::SunRiset(int year, int month, int day, double lon, double lat, double altit, int upper_limb, double &trise, double &tset) { double d, /* Days since 2000 Jan 0.0 (negative before) */ //以历元2000.0起算的日数。 sr, /* Solar distance, astronomical units */ //太阳距离,以天文单位计算(约1.5亿公里)。 sRA, /* Sun's Right Ascension */ //同前,太阳赤经。 sdec, /* Sun's declination */ //太阳赤纬。 sradius, /* Sun's apparent radius */ //太阳视半径,约16分(受日地距离、大气折射等诸多影响) t, /* Diurnal arc */ //周日弧,太阳一天在天上走过的弧长。 tsouth, /* Time when Sun is at south */ sidtime; /* Local sidereal time */ //当地恒星时,即地球的真实自转周期。比平均太阳日(日常时间)长3分56秒。 int rc = 0; /* Return cde from function - usually 0 */ /* Compute d of 12h local mean solar time */ d = Days_since_2000_Jan_0(year, month, day) + 0.5 - lon / 360.0; //计算观测地当日中午时刻对应2000.0起算的日数。 /* Compute local sideral time of this moment */ sidtime = Revolution(GMST0(d) + 180.0 + lon); //计算同时刻的当地恒星时(以角度为单位)。以格林尼治为基准,用经度差校正。 /* Compute Sun's RA + Decl at this moment */ sRA = 0.0; sdec = 0.0; sr = 0.0; Sun_RA_dec(d, sRA, sdec, sr); //计算同时刻太阳赤经赤纬。 /* Compute time when Sun is at south - in hours UT */ tsouth = 12.0 - Rev180(sidtime - sRA) / 15.0; //计算太阳日的正午时刻,以世界时(格林尼治平太阳时)的小时计。 /* Compute the Sun's apparent radius, degrees */ sradius = 0.2666 / sr; //太阳视半径。0.2666是一天文单位处的太阳视半径(角度)。 /* Do correction to upper limb, if necessary */ if (upper_limb != 0) altit -= sradius; //如果要用上边缘,就要扣除一个视半径。 /* Compute the diurnal arc that the Sun traverses to reach */ //计算周日弧。直接利用球面三角公式。如果碰到极昼极夜问题,同前处理。 /* the specified altitide altit: */ double cost; cost = (Sind(altit) - Sind(lat) * Sind(sdec)) / (Cosd(lat) * Cosd(sdec)); if (cost >= 1.0) { rc = -1; t = 0.0; } else { if (cost <= -1.0) { rc = +1; t = 12.0; /* Sun always above altit */ } else t = Acosd(cost) / 15.0; /* The diurnal arc, hours */ } /* Store rise and set times - in hours UT */ trise = tsouth - t; tset = tsouth + t; return rc; }