Commit 80c15ae4 authored by Eric Walsh's avatar Eric Walsh

autosave

parent 0b7178d8
......@@ -21,34 +21,12 @@ void horizontalToCart(double alt, double azi, double &x, double &y, double &z){
y = -1 * cos(alt) * sin(azi);
}
//converts the latitude to theta
double latToTheta(double lat){
double theta;
//loat L = lat * (M_PI / 180);
theta = (90 - lat);
return theta;
}
//converts the time to phi
double timeToPhi(int year, double hours, double longitude){
float phi;
float date = GMST(year, hours);
//converts the longitude into radians
float lam = longitude * (M_PI / 180);
//calculates phi;
phi = date * ((2 * M_PI) / 24) - lam;
return phi;
}
//convert the date to a julian date;
double julian(double year, double hours){
double leap = 0;
double notLeap, dayFract, dayWhole;
double julian, years, days, seconds, hoursLeft;
double years, days, hoursLeft;
years = year + 4712;//years is current year (AD or CE) 4713 is the start of the julian calender 1 is 0 AD/CE
if(DEBUG){
clog << "DEBUG: years has a value of: " << years << endl;
......@@ -102,17 +80,9 @@ 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 >= 12) { //turns the left over hours into seconds since noon (12pm)
seconds = (hoursLeft - 12) * 360;
} else {
seconds = (hoursLeft + 12) * 360;
}
} 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;
clog <<fixed << setprecision(6) << "DEBUG: Days has a value of " << days << " hoursLeft has a value of " << hoursLeft << endl;
}
//days += (seconds / 86400);
days += hoursLeft/24;
......@@ -128,34 +98,25 @@ 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 JD = julian(year, hours);
//double JDmin = floor(JD) - 0.5;
//double JDmax = floor(JD) + 0.5;
JD0 = floor(JD) + 0.5;
D = (JD - 2451545.0);
double D0 = JD0 - 2451545.0;
double D0 = JD0 - 2451545.0; // days since Jan 1st 2000 at midnight
double T = D/36525; // centuries since Jan 1st 2000 AD
hoursLeft = (JD - JD0) *24;
/*if(JD > JD0){
hoursLeft = (JD - JD0) *24;
} else {
hoursLeft = (JD0 - JD) *24;
}*/
if(DEBUG){
clog << fixed << setprecision(10) << "DEBUG: The GMST in days is: " << D << endl
<< "DEBUG: The value of JD is: " << JD << endl
<< "DEBUG: The value of JD0 is: " << JD0 << " and the value of D0 " << D0 << endl;
}
} //debugs
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) ;
} //debugs
GMST = fmod(temp, 24);
if(DEBUG){
clog << "DEBUG: GMST has a value of: " << GMST << endl;
}
......@@ -170,38 +131,35 @@ double GMST(int year, double hours){
pair<double,double> algorithm(double hours, pair<double, double> latAndLongPair, pair<double, double> altAndAziPair, int year){
//declaraton of variables
pair<double,double> raAndDecPair;
double phi = latAndLongPair.first * (M_PI / 180);
double hourAngle;
double phi = latAndLongPair.first * (M_PI / 180); // latitude
double hourAngle; //hour angle of the celestial object (used ro find alpha)
double alpha, sigma, temp;
double a = altAndAziPair.first * (M_PI / 180); // altitude
double A = altAndAziPair.second * (M_PI / 180); // azimuth
double lat = latAndLongPair.first; // latitude
double Long = latAndLongPair.second * (M_PI / 180); // longitude
double hoursLeft = modf((hours/24), &temp) * 24;
double Time = (GMST(year, hours) * 15) * (M_PI / 180);
double Time = (GMST(year, hours) * 15) * (M_PI / 180); // time is in local sidereal time
temp = ((sin(a)*sin(phi)) + (cos(a) * cos(phi) * cos(A)));
temp = ((sin(a)*sin(phi)) + (cos(a) * cos(phi) * cos(A))); //converts the altitude, azimuth, and latitude to sigma
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); // converts altiutde, azimuth, and sigma to the hourangle
alpha = (Time - Long) - asin(hourAngle);
alpha = (Time - Long) - asin(hourAngle); // converts the time, longitude and the hour angle to alpha from the equation a = t - H where t = GST - longitude west
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: " << (Time - Long) * (180 / M_PI) << " 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;
}
} // debugs
raAndDecPair.first = (alpha * (180 / M_PI)) / 15;
raAndDecPair.second = sigma * (180 / M_PI);
raAndDecPair.first = (alpha * (180 / M_PI)) / 15; //converts alpha into hours from 0 - 24
raAndDecPair.second = sigma * (180 / M_PI); // converts sigma to degrees
if(DEBUG){
clog << "DEBUG: The final point is: (" << raAndDecPair.first << "," << raAndDecPair.second << ")." << endl;
}
} // debugs
return raAndDecPair;
......
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