Commit e49a15ef by Elon Bontemps

### autosave

parent 307da63f
 #include "Algorithm.h" #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, notLeap, dayFract, dayWhole; double julian, years, days, seconds, hoursLeft; years = year + 4713 + 1;//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++; } }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++; } } } } 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; 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 >= 12){ //turns the left over hours into seconds since noon (12pm) seconds = (hoursLeft - 12) * 360; } else { seconds = (hoursLeft + 12) * 360; } if(DEBUG){ clog << "DEBUG: Days has a value of " << days << " hoursLeft has a value of " << hoursLeft << " while seconds has value of: " << seconds << endl; } days += seconds / 86400; return days; } //converts the hours and year to GMST (Greenwich Mean Sidereal Time) 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 JD, D, GMST; JD = julian(year, hours); D = JD - 2451545.0; GMST = fmod(D, 24); 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){ //the map is in celestial coordinates pair raAndDecPair; //char constellationMap[ROW_MAX][COl_MAX]; double theta = latToTheta(latAndLongPair.first); double phi = timeToPhi(year, hours, latAndLongPair.second); double x, y, z; double xPrime, yPrime, zPrime, alpha, sigma; //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); //cartesian to celestial alpha = atan2(yPrime, xPrime); sigma = asin(zPrime); raAndDecPair.first = alpha; raAndDecPair.second = sigma; 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 "Algorithm.h" #include #include #include #include #include using namespace std; int main(){ //declaration of variables double x, y, z; //testing horizontal to cart conversion function horizontalToCart(24, 46, x, y, z); cout << "When the altitude is 24 and the azimuth is 46 (in degrees):" << endl << "X = " << x << endl << "Y = " << y << endl << "Z = " << z << endl; cout << "The values should be: " << endl << "X = 0.634601998946" << endl << "Y = -0.657149607101" << endl << "Z = 0.406736643076" << endl; //converting latitude to theta cout << "if th latitude is -46, then the latToTheta function should return 136." << endl << "It actually returns: " << latToTheta(-46) << endl; //calculating the julian date cout << "if the date is January 27, 2034 at 5:45:54.6 pm, the julian date function should return 2463990.240215." << endl << "It actually returns: " << julian(2034, 641.765166667) << 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 13.24." << endl // << "Phi actually equals: " << timeToPhi(2034, 648.45, 49) << endl; }
 //North America 1. Seattle, Washington 2. Boise, Idaho 3. Helena, Montana 4. St. Paul, Minessota 5. Madison, Wisconson New York, New York, Augusta, Maine Los-Angeles, California Salt Lake City, Utah Topeka, Kansas Raleigh, North Carolina Austin, Texas Miami, Florida //South America Bogota, Columbia Brasilia, Brazil Buenos Aires, Argentina //Africa En Nahud, Sudan Agadez, Niger Kiffa, Mauritana Fes, Morocco Gamba, Gabon Kindu, Democratic Republic of the Congo Namacunde, Angola Lugela, Mozambique Camarvan, South Africa Ihosy, Madagascar //Europe Afif, Saudi Arabia Buky, Ukraine Paris, France Bor, Russia Nagpur, India Naggu, Tibet //Asia Golong, China Bogd, Mongolia Quanzhou, Fujian Busan, South Korea Nagoya, Japan //Australia //
 /**************************************************************************** * * Proj.03: A project that projects the star constellations depending on your * geographical location on Earth. * * * Name: Worked on project: Eric Walsh, Elon Bontemps, Brandon Reid, Moses Montanez * and Elizabeth * Course: CPTR 142 * Date: Due: March something 2019 * */ #include #include using namespace std; int main { //Welcomeing the user cout << "Welcome to the Star Gazer Application!" << endl; } \ No newline at end of file
FlowChart.md 0 → 100644
 Here is a link the basic flow chart for the project. https://www.draw.io/#Wb!guP8I1MO6ky9qAikuFEYdLh_2q1TOJhAkB3FyycKJcm_QH70etj2ToguSQZ86C9_%2F01NFLHWNY56BBBXZXNWBGYLOZJAG3KN7Z7
Functions.cpp 0 → 100644