Commit a3840ab8 authored by Brandon Reid's avatar Brandon Reid

autosave

parents 7df7964f 1158dcb2
......@@ -168,47 +168,36 @@ double GMST(int year, double hours){
//latAndLongpair has lat as the first and long as the second
//alt and azi pair has altitude as the first and azimuth as the second
pair<double,double> algorithm(double hours, pair<double, double> latAndLongPair, pair<double, double> altAndAziPair, int year){
//the map is in celestial coordinates
//declaraton of variables
pair<double,double> raAndDecPair;
//char constellationMap[ROW_MAX][COl_MAX];
//double theta = latToTheta(latAndLongPair.first);
//double phi = timeToPhi(year, hours, latAndLongPair.second);
double phi = latAndLongPair.first * (M_PI / 180);
double hourAngle;
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; // longitude
double Long = latAndLongPair.second * (M_PI / 180); // longitude
double hoursLeft = modf((hours/24), &temp) * 24;
//double x, y, z;
//double xPrime, yPrime, zPrime, alpha, sigma;
double Time = (GMST(year, hours) * 15) * (M_PI / 180);
//converting the horizontal coordinates to cartesian coordinates
//horizontalToCart(altAndAziPair.first, altAndAziPair.second, x, y , z);
//xPrime = (x*cos(phi)*cos(theta)) + y*sin(phi) + (z*cos(phi)*sin(theta));
//yPrime = (-1*x*sin(phi)*cos(theta)) + y*cos(theta) + (-1*z*sin(phi)*sin(theta));
//zPrime = (-1*x*sin(theta)) + z*cos(theta);
temp = ((sin(a)*sin(phi)) + (cos(a) * cos(phi) * cos(A)));
sigma = asin(temp);
hourAngle = (-1 * sin(A) * cos(a)) / cos(sigma);
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) - (asin(hourAngle) * (180 / M_PI));
alpha = (Time - Long) - asin(hourAngle);
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: " << asin(hourAngle) * (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;
}
raAndDecPair.first = alpha;
raAndDecPair.first = (alpha * (180 / M_PI)) / 15;
raAndDecPair.second = sigma * (180 / M_PI);
if(DEBUG){
clog << "DEBUG: The final point is: (" << raAndDecPair.first << "," << raAndDecPair.second << ")." << endl;
......
......@@ -168,47 +168,36 @@ double GMST(int year, double hours){
//latAndLongpair has lat as the first and long as the second
//alt and azi pair has altitude as the first and azimuth as the second
pair<double,double> algorithm(double hours, pair<double, double> latAndLongPair, pair<double, double> altAndAziPair, int year){
//the map is in celestial coordinates
//declaraton of variables
pair<double,double> raAndDecPair;
//char constellationMap[ROW_MAX][COl_MAX];
//double theta = latToTheta(latAndLongPair.first);
//double phi = timeToPhi(year, hours, latAndLongPair.second);
double phi = latAndLongPair.first * (M_PI / 180);
double hourAngle;
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; // longitude
double Long = latAndLongPair.second * (M_PI / 180); // longitude
double hoursLeft = modf((hours/24), &temp) * 24;
//double x, y, z;
//double xPrime, yPrime, zPrime, alpha, sigma;
double Time = (GMST(year, hours) * 15) * (M_PI / 180);
//converting the horizontal coordinates to cartesian coordinates
//horizontalToCart(altAndAziPair.first, altAndAziPair.second, x, y , z);
//xPrime = (x*cos(phi)*cos(theta)) + y*sin(phi) + (z*cos(phi)*sin(theta));
//yPrime = (-1*x*sin(phi)*cos(theta)) + y*cos(theta) + (-1*z*sin(phi)*sin(theta));
//zPrime = (-1*x*sin(theta)) + z*cos(theta);
temp = ((sin(a)*sin(phi)) + (cos(a) * cos(phi) * cos(A)));
sigma = asin(temp);
hourAngle = (-1 * sin(A) * cos(a)) / cos(sigma);
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) - (asin(hourAngle) * (180 / M_PI));
alpha = (Time - Long) - asin(hourAngle);
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: " << asin(hourAngle) * (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;
}
raAndDecPair.first = alpha;
raAndDecPair.first = (alpha * (180 / M_PI)) / 15;
raAndDecPair.second = sigma * (180 / M_PI);
if(DEBUG){
clog << "DEBUG: The final point is: (" << raAndDecPair.first << "," << raAndDecPair.second << ")." << endl;
......
......@@ -61,7 +61,11 @@ int main () {
hoursSinceYear = dateToHour(monthInput, monthDay, hourInput, minuteInput);
pair<double,double> returnValue;
<<<<<<< HEAD
returnValue = algorithm(hoursSinceYear, longAndLatPair, AltAndAziPair, yearInput);
=======
returnValue = algorithm(641.9, longAndLatPair, AltAndAziPair, yearInput);
>>>>>>> 1158dcb2b2dea1b1f51b42e5dda3a932661613e9
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