### autosave

parent bd43800b
 ... ... @@ -118,27 +118,28 @@ double julian(double year, double hours){ //converts the hours and year to GMST (Greenwich Mean Sidereal Time) double GMST(int year, double hours){ //JD is the julian date (days since jan 1st, 4713 BC) and D is days since Jan 1st 2000 double D, GMST, temp; double hoursLeft = modf((hours/24), &temp) * 24; /*if(hoursLeft >= 12){ //turns the left over hours into hours since noon (12pm) hoursLeft = (hoursLeft - 12); } else { hoursLeft = (hoursLeft + 12); }*/ D = ((julian(year, hours) - (hoursLeft / 24)) - 2451545.0); double D, GMST, temp, JD0; double hoursLeft = modf((hours/24), &temp) * 24; // hours since the previous midnight //hoursLeft = (hoursLeft + 12); double JD = julian(year, hours); //double JDmin = floor(JD) - 0.5; //double JDmax = floor(JD) + 0.5; JD0 = JD - (hoursLeft / 24); D = ( JD - 2451545.0); double D0 = JD0 - 2451545.0; double T = D/36525; // centuries since Jan 1st 2000 AD if(DEBUG){ clog << "DEBUG: The GMST in days is: " << D << endl; clog << "DEBUG: The GMST in days is: " << D << endl << "DEBUG: The value of JD0 is: " << JD0 << " and the value of D0 " << D0 << endl; } //temp = 67310.5481 + (876600* hoursLeft + 8640184.812866)*T + (0.09314 * pow(T, 2)) - ((6.2 * pow(10, -6)) * pow(T, 3)); temp = 6.697374558 + (0.06570982441908*D) + (1.00273790935*hoursLeft) + (0.000026 * pow(T, 2)); //temp = 18.697374558 + 24.06570982441908*D; temp = 6.697374558 + (0.06570982441908*D0) + (1.00273790935*hoursLeft) + (0.000026 * pow(T, 2)); if(DEBUG){ clog << fixed << "DEBUG: D has a value of: " << D << endl << "DEBUG: temp has a value of: " << temp << endl << "DEBUG: hours left has a value of: " << hoursLeft << endl; } GMST = fmod(temp, 24.0); GMST = fmod(temp, 24) ; //GMST = temp; //GMST = modf((temp/24), &D) * 24; /*if(GMST > 24){ ... ... @@ -182,17 +183,17 @@ pair algorithm(double hours, pair latAndLongPair, temp = ((sin(a)*sin(phi)) + (cos(a) * cos(phi) * cos(A))); sigma = asin(temp); //hourAngle = (-1 * sin(A) * cos(a)) / cos(sigma); hourAngle = (sin(a) - sin(sigma)*sin(phi)) / (cos(sigma) * cos(phi)); hourAngle = (sin(a) - (sin(sigma)*sin(phi))) / (cos(sigma) * cos(phi)); //cartesian to celestial //alpha = atan2(yPrime, xPrime) * (180 / M_PI); //sigma = asin(zPrime) * (180 / M_PI); alpha = (GMST(year, hours) - Long) - (acos(hourAngle) * (180 / M_PI)); alpha = (GMST(year, hours) * 15 - Long) - (acos(hourAngle) * (180 / M_PI)); if(DEBUG){ clog << fixed << setprecision(10) << "DEBUG: hourAngle has a value of: " << hourAngle << endl << "DEBUG: temp has a value of: " << temp << " and the arcsine of temp is: " << asin(temp) << endl << "DEBUG: sigma then has a value of: " << sigma * (180 / M_PI) << endl << "DEBUG: alpha has a value of: " << alpha << " which means that the LST is: " << (GMST(year, hours) + Long) << " and the hour angle is " << hourAngle << " and the arccos of the hour angle is: " << acos(hourAngle) * (180 / M_PI) << endl; << "DEBUG: alpha has a value of: " << alpha << " which means that the LST is: " << (GMST(year, hours)*15 - Long) << " and the hour angle is " << hourAngle << " and the arccos of the hour angle is: " << acos(hourAngle) * (180 / M_PI) << endl; //clog << "DEBUG: alpha has a value of: " << alpha << " and sigma has a value of: " << sigma * (180 / M_PI)<< endl; } ... ...
 ... ... @@ -32,8 +32,8 @@ int main(){ << "It actually returns: " << julian(2017, 641.9) << endl; cout << "if the date is January 27, 2017 at 5:45:54.6 pm, the GMST date function should return: 2.34623833333." << endl << "It actually returns: " << GMST(2017, 641.9) << endl; cout << "if the date is January 1, 2000 at 00:00:00, the GMST date function should return: 6.79519916667." << endl << "It actually returns: " << GMST(2000, 0) << endl; //converting time and longitude to phi /*cout << "if its January 27, 2034, 5:45 pm at a longitude of 49 the, phi should equal 4.65147698949." << endl << "Phi actually equals: " << timeToPhi(2034, 641.765166667, 49) << endl;*/ ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!