Commit 86672a21 authored by Eric Walsh's avatar Eric Walsh

autosave

parent 47f89c3e
......@@ -102,7 +102,7 @@ double julian(double year, double hours){
}
days += dayWhole;
hoursLeft = dayFract * 24;//counts the left over hours that aren't days
if(hoursLeft != 0){
/*if(hoursLeft != 0){
if(hoursLeft >= 12) { //turns the left over hours into seconds since noon (12pm)
seconds = (hoursLeft - 12) * 360;
} else {
......@@ -110,12 +110,17 @@ double julian(double year, double hours){
}
} else {
//seconds = 43200;
}*/
if(DEBUG){
clog <<fixed << setprecision(6) << "DEBUG: Days has a value of " << days << " hoursLeft has a value of " << hoursLeft << " while seconds has value of: " << seconds << endl;
}
//days += (seconds / 86400);
days += hoursLeft/24;
days -= 1;
days += 0.5;
if(DEBUG){
clog << "DEBUG: Days has a value of " << days << " hoursLeft has a value of " << hoursLeft << " while seconds has value of: " << seconds << endl;
clog << "DEBUG: the julian date is: " << days << endl;
}
days += (seconds / 86400);
return days;
}
......@@ -123,8 +128,8 @@ double julian(double year, double hours){
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, JD0;
double hoursLeft = modf((hours/24), &temp) * 24; // hours since the previous midnight
//double hoursLeft;
//double hoursLeft = modf((hours/24), &temp) * 24; // hours since the previous midnight
double hoursLeft;
double JD = julian(year, hours);
//double JDmin = floor(JD) - 0.5;
//double JDmax = floor(JD) + 0.5;
......@@ -132,7 +137,7 @@ double GMST(int year, double hours){
D = (JD - 2451545.0);
double D0 = JD0 - 2451545.0;
double T = D/36525; // centuries since Jan 1st 2000 AD
//hoursLeft = (JD - JD0) *24;
hoursLeft = (JD - JD0) *24;
/*if(JD > JD0){
hoursLeft = (JD - JD0) *24;
} else {
......@@ -144,18 +149,13 @@ double GMST(int year, double hours){
<< "DEBUG: The value of JD0 is: " << JD0 << " and the value of D0 " << D0 << endl;
}
temp = 6.697374558 + (0.06570982441908*D0) + (1.00273790935*hoursLeft) + (0.000026 * pow(T, 2));
//temp =
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) ;
//GMST = temp;
//GMST = modf((temp/24), &D) * 24;
/*if(GMST > 24){
GMST -= 24;
}*/
if(DEBUG){
clog << "DEBUG: GMST has a value of: " << GMST << endl;
}
......@@ -193,23 +193,26 @@ pair<double,double> algorithm(double hours, pair<double, double> 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 = (-1 * sin(A) * cos(a)) / cos(sigma);
//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) * 15 - Long) - (acos(hourAngle) * (180 / M_PI));
alpha = (GMST(year, hours) * 15 - Long) - (asin(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)*15 - 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: " << asin(hourAngle) * (180 / M_PI) << endl;
//clog << "DEBUG: alpha has a value of: " << alpha << " and sigma has a value of: " << sigma * (180 / M_PI)<< endl;
}
raAndDecPair.first = alpha;
raAndDecPair.second = sigma * (180 / M_PI);
if(DEBUG){
clog << "DEBUG: The final point is: (" << raAndDecPair.first << "," << raAndDecPair.second << ")." << endl;
}
return raAndDecPair;
......
......@@ -32,7 +32,7 @@ int main(){
<< "It actually returns: " << julian(2017, 641.9) << endl;
cout << "if the date is January 1, 2019 at 08:00:00, the GMST date function should return: 6.79519916667." << endl
cout << "if the date is January 1, 2000 at 08:00:00, the GMST date function should return: 6.79519916667." << endl
<< "It actually returns: " << GMST(2019, 8) << 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
......@@ -46,7 +46,7 @@ int main(){
horizontal.first = 20;
horizontal.second = 270;
pair<double,double> returnValue;
returnValue = algorithm(641.9, test, horizontal, 2017);
returnValue = algorithm(8, test, horizontal, 2019);
cout << "The algorithm function, when its January 27, 2017, at 5:45:54 pm, at a lat and long of -46,89 and when looking at the sky at 20, 270 (in horizontal coordinates), gives: " << endl
<< "Right ascention of: " << returnValue.first << " and a declination of: " << returnValue.second << endl;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment