autosave

parents 0b8883ea 6abdd7bc
 ... ... @@ -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 < 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; } 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; } ... ... @@ -163,48 +168,40 @@ 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 algorithm(double hours, pair latAndLongPair, pair altAndAziPair, int year){ //the map is in celestial coordinates //declaraton of variables pair 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 = (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 = (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: " << acos(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; } return raAndDecPair; ... ...
 ... ... @@ -32,8 +32,8 @@ int main(){ << "It actually returns: " << julian(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; 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 << "Phi actually equals: " << timeToPhi(2034, 641.765166667, 49) << endl;*/ ... ... @@ -46,7 +46,9 @@ int main(){ horizontal.first = 20; horizontal.second = 270; pair 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; }
 //North America Seattle, Washington. 47.6062° N. 122.3321° W Boise, Idaho. 43.6150° N. 116.2023° W Helena, Montana. 46.5891° N. 112.0391° W Saint Paul, Minessota. 44.9537° N. 93.0900° W Madison, Wisconson. 43.0731° N. 89.4012° W New York, New York. 40.7128° N. 74.0060° W Augusta, Maine. 44.3106° N. 69.7795° W Los-Angeles, California. 34.0522° N. 118.2437° W Salt Lake City, Utah. 40.7608° N. 111.8910° W Topeka, Kansas. 39.0473° N. 95.6752° W Raleigh, North Carolina. 35.7796° N. 78.6382° W Austin, Texas. 30.2672° N. 97.7431° W Miami, Florida. 25.7617° N. 80.1918° W //South America Bogota, Columbia. 4.7110° N. 74.0721° W Brasilia, Brazil 15.8267° S. 47.9218° W Buenos Aires, Argentina 34.6037° S. 58.3816° W //Africa En Nahud, Sudan 12.6948° N. 28.4280° E Agadez, Niger 16.9742° N. 7.9865° E Kiffa, Mauritana 16.8740° N. 11.4339° W Fes, Morocco 34.0181° N. 5.0078° W Gamba, Gabon 2.7405° S. 10.0304° E Kindu, Democratic Republic of the Congo 2.9492° S. 25.9231° E Namacunde, Angola 17.3082° S. 15.8452° E Lugela, Mozambique 16.3693° S. 36.7820° E Ihosy, Madagascar 22.4009° S. 46.1279° E //Europe Afif, Saudi Arabia 23.9052° N. 42.9125° E Buky, Ukraine 49.0945° N. 30.4051° E Paris, France 48.8566° N. 2.3522° E Bor, Russia 56.3588° N. 44.0767° E Nagpur, India 21.1458° N. 79.0882° E Naggu, Tibet 31.4762° N. 92.0512° E //Asia Bogd, Mongolia 44.6692° N. 102.1719° E Quanzhou, Fujian 24.8741° N. 118.6757° E Busan, South Korea 35.1796° N. 129.0756° E Nagoya, Japan 35.1814° N. 136.9064° E //Australia Kalgorie, Australia 30.7490° S. 121.4660° E Coober Pedy, South Australia. 29.0139° S. 134.7533° E Newman, Western Australia. 23.3593° S. 119.7350° E Sydney, Australia 33.8688° S. 151.2093° E
 ... ... @@ -12,14 +12,23 @@ */ #include #include "countries.cpp" #include #include using namespace std; int main { int main () { //Welcomeing the user cout << "Welcome to the Star Gazer Application!" << endl; //printCities(); longAndLat (); return 0; } \ No newline at end of file
 #include "Algorithm.h" #include #include #include #include #include const bool DEBUG = true; //the main algorithm function converts using namespace std; //const int COl_MAX = 24; //const int ROW_MAX = 180; //converts horizontal coordinates to cartesian coordinates in xyz where alt is the altitude angle and azi is Azimuth angle void horizontalToCart(double alt, double azi, double &x, double &y, double &z){ //convertion of Horizontal coordinates to cartesian coordinates alt = alt * (M_PI / 180); azi = azi * (M_PI / 180); z = sin(alt); x = cos(alt) * cos(azi); 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; 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; } for(int i = -4713; i <= year; i++){ //counts number of leap years if(i < 1582){//before the switch to gregorian calenders, leap years were every 4 years if(i % 4 == 0){ leap++; /* if(DEBUG){ clog <<"DEBUG: " << i << " is a leap year." << endl; } */ } }else{ //after the switch the gregorian calenders, leap years weren't counted on centries unless it was divisible by 0 if(i % 4 == 0){ if(i % 100 == 0){ if(DEBUG){ clog << "DEBUG: The year is " << i; } if(i % 400 == 0){ leap++; if(DEBUG){ clog << ", and its a leap year." << endl; } } else { if(DEBUG){ clog << endl; } } } else { leap++; /* if(DEBUG){ clog << "DEBUG: " << i << " is a leap year." << endl; } */ } } } } notLeap = years - leap; if(DEBUG){ clog << "DEBUG: There are " << leap << " leap years and " << notLeap << " non leap years totalling " << leap + notLeap << " years." << endl; } days = (leap * 366) + (notLeap * 365) - 10; if(DEBUG){ clog << "DEBUG: days of leap years is: " << leap * 366 << ". Days of non leap years is: " << notLeap * 365 <<"." << endl << "DEBUG: The current value of Days is: " << days << endl; } dayFract = modf((hours / 24), &dayWhole); if(DEBUG){ clog << "DEBUG: The value of dayFract is: " << dayFract << " and the value of dayWhole is: " << dayWhole << endl; } 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 < 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; } 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) ; if(DEBUG){ clog << "DEBUG: GMST has a value of: " << GMST << endl; } return GMST; } //converts geographic coordinates to celestial coooriantes (right ascention and deckination) and retruns a deque with the names of all the constellations //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 algorithm(double hours, pair latAndLongPair, pair altAndAziPair, int year){ //declaraton of variables pair raAndDecPair; 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 * (M_PI / 180); // longitude double hoursLeft = modf((hours/24), &temp) * 24; double Time = (GMST(year, hours) * 15) * (M_PI / 180); 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)); 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: " << (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 * (180 / M_PI)) / 15; raAndDecPair.second = sigma * (180 / M_PI); if(DEBUG){ clog << "DEBUG: The final point is: (" << raAndDecPair.first << "," << raAndDecPair.second << ")." << endl; } return raAndDecPair; }
 #ifndef ALGORITHM_H #define ALGORITHM_H #include #include #include #include using namespace std; //converts horizontal coordinates to cartesian coordinates in xyz void horizontalToCart(double alt, double azi, double &x, double &y, double &z); //converts the latitude to theta double latToTheta(double lat); //converts the time to phi double timeToPhi(int year, double hours, double longitude); //converts the hours and year to GMST double GMST(int year, double hours); //convert the date to a julian date; double julian(double year, double hours); //converts geographic coordinates to celestial coooriantes pair algorithm(double hours, pair latAndLongPair, pair altAndAziPair, int year); #endif \ No newline at end of file
 #include "Functions.h" #include "Stars.h" #include "Constellation.h" #include #include #include ... ... @@ -24,7 +23,7 @@ int yearPrompt () { // empty argument if (isLeap(year)) { // Tells user if it is a leap year of not cout << "This is a leap year." << endl; } else if (!isLeap(year)) { cout << "This is not a leap yar." << endl; cout << "This is not a leap year." << endl; } if (year > 0 && year < 9099) { return year; ... ... @@ -37,7 +36,7 @@ int yearPrompt () { // empty argument string monthPrompt () { string month; do { cout << "Enter month: "; cout << "Enter month (ex.April, May): "; cin >> month; if (month == "January" || month == "February" || month == "March" || month == "April" || month == "May" || month == "June" || month == "July" || month == "August" || month == "September" || month == "October" || month == "November" || month == "December") { return month; ... ... @@ -442,348 +441,260 @@ vector > viewFinder (pair centerPt) { // f vector > constellationCoordinates () { // Function to store the coordinates of the constellations vector > coordinates; // Canis Major pair pair1a; pair1a = make_pair(7.45, -9.0); coordinates.push_back(pair1a); pair pair1b; pair1b = make_pair(6.1, -9.0); coordinates.push_back(pair1b); pair pair1c; pair1c = make_pair(7.45, -33.0); coordinates.push_back(pair1c); pair pair1d; pair1d = make_pair(6.1, -33.0); coordinates.push_back(pair1d); coordinates.push_back(make_pair(7.45, -9.0)); coordinates.push_back(make_pair(6.1, -9.0)); coordinates.push_back(make_pair(7.45, -33.0)); coordinates.push_back(make_pair(6.1, -33.0)); //Eridanius pair pair2a; pair2a = make_pair(5.1, -.3); coordinates.push_back(pair2a); pair pair2b; pair2b = make_pair(1.6, -.3); coordinates.push_back(pair2b); pair pair2c; pair2c = make_pair(5.1, -59.0); coordinates.push_back(pair2c); pair pair2d; pair2d = make_pair(1.6, -59.0); coordinates.push_back(pair2d); coordinates.push_back(make_pair(5.1, -0.3)); coordinates.push_back(make_pair(1.6, -0.3)); coordinates.push_back(make_pair(5.1, -59.0)); coordinates.push_back(make_pair(1.6, -59.0)); // Gemini pair pair3a; pair3a = make_pair(8.1, 35.0); coordinates.push_back(pair3a); pair pair3b; pair3b = make_pair(6.1, 35.0); coordinates.push_back(pair3b); pair pair3c; pair3c = make_pair(8.1, 10.1); coordinates.push_back(pair3c); pair pair3d; pair3d = make_pair(6.1, 10.1); coordinates.push_back(pair3d); coordinates.push_back(make_pair(8.1, 35.0)); coordinates.push_back(make_pair(6.1, 35.0)); coordinates.push_back(make_pair(8.1, 10.1)); coordinates.push_back(make_pair(6.1, 10.1)); // Orion pair pair4a; pair4a = make_pair(6.3, 25.0); coordinates.push_back(pair4a); pair pair4b; pair4b = make_pair(4.7, 25.0); coordinates.push_back(pair4b); pair pair4c; pair4c = make_pair(6.3, -10.0); coordinates.push_back(pair4c); pair pair4d; pair4d = make_pair(4.7, -10.0); coordinates.push_back(pair4d); coordinates.push_back(make_pair(6.3, 25.0)); coordinates.push_back(make_pair(4.7, 25.0)); coordinates.push_back(make_pair(6.3, -10.0)); coordinates.push_back(make_pair(4.7, -10.0)); // Tarus pair pair5a; pair5a = make_pair(6.7, 30.0); coordinates.push_back(pair5a); pair pair5b; pair5b = make_pair(3.5, 30.0); coordinates.push_back(pair5b); pair pair5c; pair5c = make_pair(6.7, 0); coordinates.push_back(pair5c); pair pair5d; pair5d = make_pair(3.5, 0); coordinates.push_back(pair5d); coordinates.push_back(make_pair(6.7, 30.0)); coordinates.push_back(make_pair(3.5, 30.0)); coordinates.push_back(make_pair(6.7, 0)); coordinates.push_back(make_pair(3.5, 0)); // Bootes pair pair6a; pair6a = make_pair(16.4, 53.0); coordinates.push_back(pair6a); pair pair6b; pair6b = make_pair(13.8, 53.0);