diff --git a/Countries/main.cpp b/Countries(Elon)/main.cpp similarity index 100% rename from Countries/main.cpp rename to Countries(Elon)/main.cpp diff --git a/Final stuff(M & B)/Algorithm.cpp b/Final stuff(M & B)/Algorithm.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64f5b2d482591e1b316a1959147f166da8b7037f --- /dev/null +++ b/Final stuff(M & B)/Algorithm.cpp @@ -0,0 +1,210 @@ +#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; + +} + + diff --git a/Final stuff/Algorithm.h b/Final stuff(M & B)/Algorithm.h similarity index 100% rename from Final stuff/Algorithm.h rename to Final stuff(M & B)/Algorithm.h diff --git a/Final stuff/Functions.cpp b/Final stuff(M & B)/Functions.cpp similarity index 100% rename from Final stuff/Functions.cpp rename to Final stuff(M & B)/Functions.cpp diff --git a/Final stuff(M & B)/Functions.h b/Final stuff(M & B)/Functions.h new file mode 100644 index 0000000000000000000000000000000000000000..fc40c48d814af40bf11f3abb9bd03a47565b2940 --- /dev/null +++ b/Final stuff(M & B)/Functions.h @@ -0,0 +1,30 @@ +#include +#include +using namespace std; + + +int yearPrompt (); // Prompts and checks year input + +string monthPrompt (); // Prompts and checks month input + +int dayPrompt (string month, int year); // Prompts and checks day input + +int hourPrompt (); // Prompts and checks hour input + +int minutePrompt (); // Prompts and checks minute input + +double dateToHour (string month, int year, int day, int hour, int minute); // Converts full date to hour + +pair altAndAziPair (); // Creates pair of alitutude and azimuth + +bool isLeap (int year); // Bool check for leap year + +vector > viewFinder (pair centerPt); // function that returns the coordinates of the viewing window + +vector > constellationCoordinates (); // function that stores the coordinates of all the constellations + +void printConstellation (vector > constellationCoordinates, vector > window); // function to print the constellations + +string constellationNamer (int index); // funciton to name all the constellations + +void constellationOutputter (int index); // function to output the images of the constellations \ No newline at end of file diff --git a/Final stuff/Stars.cpp b/Final stuff(M & B)/Stars.cpp similarity index 100% rename from Final stuff/Stars.cpp rename to Final stuff(M & B)/Stars.cpp diff --git a/Final stuff/Stars.h b/Final stuff(M & B)/Stars.h similarity index 100% rename from Final stuff/Stars.h rename to Final stuff(M & B)/Stars.h diff --git a/Final stuff/coordinates.txt b/Final stuff(M & B)/coordinates.txt similarity index 100% rename from Final stuff/coordinates.txt rename to Final stuff(M & B)/coordinates.txt diff --git a/Final stuff/countries.cpp b/Final stuff(M & B)/countries.cpp similarity index 100% rename from Final stuff/countries.cpp rename to Final stuff(M & B)/countries.cpp diff --git a/Final stuff/countries.h b/Final stuff(M & B)/countries.h similarity index 100% rename from Final stuff/countries.h rename to Final stuff(M & B)/countries.h diff --git a/Final stuff/countries.txt b/Final stuff(M & B)/countries.txt similarity index 100% rename from Final stuff/countries.txt rename to Final stuff(M & B)/countries.txt diff --git a/Final stuff(M & B)/main.cpp b/Final stuff(M & B)/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f7294e6b1c520808bf5fb37081c75f83706483c6 --- /dev/null +++ b/Final stuff(M & B)/main.cpp @@ -0,0 +1,81 @@ +#include +#include "Functions.h" +#include "countries.h" +#include "Algorithm.h" +#include +#include +#include + +using namespace std; + +int main () { + //variables + string monthInput; + char endMenu; + int monthDay = 0; + int yearInput = 0; + int hourInput = 0; + int minuteInput = 0; + double hoursSinceYear = 0; + pair AltAndAziPair; + pair longAndLatPair; + vector > window; + vector > coordinates; + + + cout << "==============Welcome to the Star-Gazer v 1.0==============" << endl; + do { + yearInput = yearPrompt(); + + monthInput = monthPrompt(); + + monthDay = dayPrompt(monthInput, yearInput); + + hourInput = hourPrompt(); + + minuteInput = minutePrompt(); + + AltAndAziPair = altAndAziPair (); + + printCities(); + + longAndLatPair = longAndLat(); + + //calculating the julian date + // cout << "if the date is January 27, 2017 at 5:45:54.6 pm, the julian date function should return 2457781.240208." << endl + // << "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; + // //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;*/ + + //test the algorithm as a whole + // pair test; + // test.first = -46; + // test.second = 89; + // pair horizontal; + // horizontal.first = 20; + // horizontal.second = 270; + hoursSinceYear = dateToHour(monthInput, yearInput, monthDay, hourInput, minuteInput); + + pair returnValue; + returnValue = algorithm(hoursSinceYear, longAndLatPair, AltAndAziPair, yearInput); + 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; + + window = viewFinder(returnValue); + coordinates = constellationCoordinates(); + + printConstellation(coordinates, window); + + + + } while (false); + + + //cout << dateToHour(yearInput, monthInput, monthDay, hourInput, minuteInput) << endl; + return 0; +} \ No newline at end of file diff --git a/README.md b/README.md index 14741ddd7c7c624ff366a6f39afa04df0e1963ff..9e89bd0efc2e2923a438c1d7dee77543e7656526 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +Prefice: We haven't mapped every constellation which means according to our code +there will be points and times where there will be no constellations. Project 3 things: Libraries: - locations @@ -23,4 +25,7 @@ Who does what (tentative): - Algorithm (Eric) - -The project that Eric, Brandon \ No newline at end of file +- star.cpp/h: Elizabeth +- coordinates/countries: Elon +- Algorithm.cpp/h: Eric +- Functions/main.cpp: Brandon and Moses \ No newline at end of file diff --git a/Star Array(Elizabeth)/main.cpp b/Star Array(Elizabeth)/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a6fa7b77d58f224a214b1bcfd4aea4cf234515e2 --- /dev/null +++ b/Star Array(Elizabeth)/main.cpp @@ -0,0 +1,19 @@ +/********************************** + * File: main.cpp + * Description: testing file + * **************************/ + +#include +#include "Stars.h" +using namespace std; + +int main() { + + Stars s; + s.Pegasus(); + + + + + return 0; +} \ No newline at end of file