kstars
kssun.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <math.h>
00019 #include <qdatetime.h>
00020
00021 #include "kssun.h"
00022 #include "ksutils.h"
00023 #include "ksnumbers.h"
00024 #include "kstarsdatetime.h"
00025
00026 KSSun::KSSun( KStarsData *kd, QString fn, double pSize ) : KSPlanet( kd, I18N_NOOP( "Sun" ), fn, pSize ) {
00027
00028
00029
00030
00031
00032
00033 setMag( -26.73 );
00034 }
00035
00036 bool KSSun::loadData() {
00037
00038 return (odm.loadData("earth") != 0);
00039 }
00040
00041 bool KSSun::findGeocentricPosition( const KSNumbers *num, const KSPlanetBase *Earth ) {
00042 if (Earth) {
00043
00044
00045
00046
00047
00048 double delay = (.0057755183 * Earth->rsun()) / 365250.0;
00049
00050
00051
00052
00053
00054 const KSPlanet *pEarth = dynamic_cast<const KSPlanet *>(Earth);
00055
00056
00057 EclipticPosition trialpos;
00058 pEarth->calcEcliptic(num->julianMillenia() - delay, trialpos);
00059
00060 setEcLong( trialpos.longitude.Degrees() + 180.0 );
00061 setEcLong( ecLong()->reduce().Degrees() );
00062 setEcLat( -1.0*trialpos.latitude.Degrees() );
00063
00064 } else {
00065 double sum[6];
00066 dms EarthLong, EarthLat;
00067 OrbitDataColl * odc;
00068 double T = num->julianMillenia();
00069 double Tpow[6];
00070
00071 Tpow[0] = 1.0;
00072 for (int i=1; i<6; ++i) {
00073 Tpow[i] = Tpow[i-1] * T;
00074 }
00075
00076
00077 if (!(odc = odm.loadData("earth"))) return false;
00078
00079
00080 for (int i=0; i<6; ++i) {
00081 sum[i] = 0.0;
00082 for (uint j = 0; j < odc->Lon[i].size(); ++j) {
00083 sum[i] += odc->Lon[i][j]->A * cos( odc->Lon[i][j]->B + odc->Lon[i][j]->C*T );
00084 }
00085 sum[i] *= Tpow[i];
00086
00087 }
00088
00089 EarthLong.setRadians( sum[0] + sum[1] + sum[2] +
00090 sum[3] + sum[4] + sum[5] );
00091 EarthLong.setD( EarthLong.reduce().Degrees() );
00092
00093
00094 for (int i=0; i<6; ++i) {
00095 sum[i] = 0.0;
00096 for (uint j = 0; j < odc->Lat[i].size(); ++j) {
00097 sum[i] += odc->Lat[i][j]->A * cos( odc->Lat[i][j]->B + odc->Lat[i][j]->C*T );
00098 }
00099 sum[i] *= Tpow[i];
00100 }
00101
00102
00103 EarthLat.setRadians( sum[0] + sum[1] + sum[2] + sum[3] +
00104 sum[4] + sum[5] );
00105
00106
00107 for (int i=0; i<6; ++i) {
00108 sum[i] = 0.0;
00109 for (uint j = 0; j < odc->Dst[i].size(); ++j) {
00110 sum[i] += odc->Dst[i][j]->A * cos( odc->Dst[i][j]->B + odc->Dst[i][j]->C*T );
00111 }
00112 sum[i] *= Tpow[i];
00113 }
00114
00115 ep.radius = sum[0] + sum[1] + sum[2] + sum[3] + sum[4] + sum[5];
00116
00117 setEcLong( EarthLong.Degrees() + 180.0 );
00118 setEcLong( ecLong()->reduce().Degrees() );
00119 setEcLat( -1.0*EarthLat.Degrees() );
00120 }
00121
00122
00123 EclipticToEquatorial( num->obliquity() );
00124
00125 nutate(num);
00126 aberrate(num);
00127
00128
00129
00130 EquatorialToEcliptic( num->obliquity() );
00131
00132
00133 findPA( num );
00134
00135 return true;
00136 }
00137
00138 long double KSSun::springEquinox(int year) {
00139 return equinox(year, 18, 3, 0.);
00140 }
00141
00142 long double KSSun::summerSolstice(int year) {
00143 return equinox(year, 18, 6, 90.);
00144 }
00145
00146 long double KSSun::autumnEquinox(int year) {
00147 return equinox(year, 19, 9, 180.);
00148 }
00149
00150 long double KSSun::winterSolstice(int year) {
00151 return equinox(year, 18, 12, 270.);
00152 }
00153
00154 long double KSSun::equinox(int year, int d, int m, double angle) {
00155 long double jd0[5];
00156 long double eclipticLongitude[5];
00157
00158 for(int i = 0; i<5; ++i) {
00159 jd0[i] = KStarsDateTime( ExtDate(year,m,d+i), QTime(0,0,0) ).djd();
00160 KSNumbers *ksn = new KSNumbers(jd0[i]);
00161
00162 findGeocentricPosition( ksn );
00163 delete ksn;
00164 eclipticLongitude[i] = (long double)ecLong()->Degrees();
00165 }
00166
00167 return KSUtils::lagrangeInterpolation( eclipticLongitude, jd0, 5, angle );
00168 }