Commit 4c19c96a authored by Elon Bontemps's avatar Elon Bontemps

autosave

parents 58e98b47 37558b03
#include <iostream>
#include "Functions.h"
#include "countries.h"
#include "Algorithm.h"
#include <vector>
#include <string>
#include <utility>
using namespace std;
int main () {
//variables
string monthInput;
int monthDay = 0;
int yearInput = 0;
int hourInput = 0;
int minuteInput = 0;
double hoursSinceYear = 0;
pair <double,double> AltAndAziPair;
pair <double, double> longAndLatPair;
vector <pair<double,double>> window;
vector <pair<double,double>> 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();
hoursSinceYear = dateToHour(monthInput, yearInput, monthDay, hourInput, minuteInput);
pair<double,double> 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 (!restart());
//cout << dateToHour(yearInput, monthInput, monthDay, hourInput, minuteInput) << endl;
return 0;
}
\ No newline at end of file
/***************
* Made by Eric Walsh
* ***************/
#include "Algorithm.h"
#include <deque>
#include <utility>
#include <cmath>
#include <iostream>
#include <iomanip>
const bool DEBUG = true;
const bool DEBUG = false;
//the main algorithm function converts
using namespace std;
......@@ -21,34 +24,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 +83,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 +101,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 +134,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;
......
/***************
* Made by Brandon Reid and Moses Montanez
* ***************/
#include "Functions.h"
#include "Stars.h"
#include <string>
......@@ -542,6 +547,60 @@ vector <pair<double, double>> constellationCoordinates () { // Function to store
coordinates.push_back(make_pair(8.6, 61.0));
coordinates.push_back(make_pair(13.7, 32.0));
coordinates.push_back(make_pair(8.6, 32.0));
//Hercules
coordinates.push_back(make_pair(18.1, 57.0));
coordinates.push_back(make_pair(16.0, 57.0));
coordinates.push_back(make_pair(18.1, 12.0));
coordinates.push_back(make_pair(16.0, 12.0));
//Cygnus
coordinates.push_back(make_pair(21.1, 53.0));
coordinates.push_back(make_pair(19.1, 53.0));
coordinates.push_back(make_pair(21.1, 29.0));
coordinates.push_back(make_pair(19.1, 29.0));
//Pavo
coordinates.push_back(make_pair(21.5, -58.0));
coordinates.push_back(make_pair(17.9, -58.0));
coordinates.push_back(make_pair(21.5, -74.0));
coordinates.push_back(make_pair(17.9, -74.0));
//Centaurus
coordinates.push_back(make_pair(14.6, -38.0));
coordinates.push_back(make_pair(11.3, -38.0));
coordinates.push_back(make_pair(14.6, -64.0));
coordinates.push_back(make_pair(11.3, -64.0));
//Canes Venatici
coordinates.push_back(make_pair(13.0, 42.0));
coordinates.push_back(make_pair(12.5, 42.0));
coordinates.push_back(make_pair(13.0, 38.0));
coordinates.push_back(make_pair(12.5, 38.0));
//Lynx
coordinates.push_back(make_pair(9.4, 60.0));
coordinates.push_back(make_pair(6.4, 60.0));
coordinates.push_back(make_pair(9.4, 37.0));
coordinates.push_back(make_pair(6.4, 37.0));
//Auriga
coordinates.push_back(make_pair(6, 46.0));
coordinates.push_back(make_pair(5, 46.0));
coordinates.push_back(make_pair(6, 30.0));
coordinates.push_back(make_pair(5, 30.0));
//Hydra
coordinates.push_back(make_pair(14.2, 8.0));
coordinates.push_back(make_pair(8.6, 8.0));
coordinates.push_back(make_pair(14.2, -35.0));
coordinates.push_back(make_pair(8.6, -35.0));
//Vela
coordinates.push_back(make_pair(10.8, -42.0));
coordinates.push_back(make_pair(8.3, -42.0));
coordinates.push_back(make_pair(10.8, -55.0));
coordinates.push_back(make_pair(8.3, -55.0));
return coordinates;
}
......@@ -560,7 +619,7 @@ void printConstellation (vector <pair<double,double>> constellationCoordinates,
inrangeCount = 0;
for (int i = 0; i < 4; i++) {
coordinateCount++;
if((windowLeft > constellationCoordinates.at(coordinateCount).first) && (constellationCoordinates.at(coordinateCount).first < windowRight)
if((windowLeft > constellationCoordinates.at(coordinateCount).first) && (constellationCoordinates.at(coordinateCount).first < windowRight) // checks if specific constellation point falls within window boundaries
&& (windowTop > constellationCoordinates.at(coordinateCount).second) && (constellationCoordinates.at(coordinateCount).second > windowBottom)) {
inrangeCount++;
}
......@@ -618,6 +677,24 @@ string constellationNamer (int index) {
return " Ursa Minor ";
case 67:
return " Ursa Major ";
case 71:
return " Hercules ";
case 75:
return " Cygnus ";
case 79:
return " Pavo ";
case 83:
return " Centaurus ";
case 87:
return " Canes Venatici ";
case 91:
return " Lynx ";
case 95:
return " Auriga ";
case 99:
return " Hydra ";
case 103:
return " Vela ";
default:
return " Unknown constellation ";
}
......@@ -694,7 +771,66 @@ void constellationOutputter (int index) {
a.UrsaMajor16();
cout << endl;
break;
case 71:
a.Hercules17();
cout << endl;
break;
case 75:
a.Cygnus18();
cout << endl;
break;
case 79:
a.Pavo19();
cout << endl;
break;
case 83:
a.Centaurus20();
cout << endl;
break;
case 87:
a.CanesVenatici21();
cout << endl;
break;
case 91:
a.Lynx22();
cout << endl;
break;
case 95:
a.Auriga23();
cout << endl;
break;
case 99:
a.Hydra24();
cout << endl;
break;
case 103:
a.Vela25();
cout << endl;
break;
default:
cout << endl;
}
}
bool restart(){
bool goodInput;
char input;
cout << "Would you like to quit? (y/n): " << endl;
do{
cin >> input;
if(input != 'y' && input != 'n'){
goodInput = false;
cerr << "Error: Invalid input. Try again." << endl;
cin.clear();
} else {
goodInput = true;
}
} while(!goodInput);
if (input == 'y'){
return false;
} else {
return true;
}
}
\ No newline at end of file
......@@ -27,4 +27,6 @@ void printConstellation (vector <pair<double,double>> constellationCoordinates,
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
void constellationOutputter (int index); // function to output the images of the constellations
bool restart(); // function to ask for restart options
\ No newline at end of file
......@@ -2,6 +2,7 @@
* File: Constellation.cpp
* Description: functions to output a certain constellation depending
* on the funcation name.
* Made by Elizabeth Ventura
* *****************/
#include "Stars.h"
#include <iostream>
......@@ -571,7 +572,7 @@ void Stars::UrsaMajor16() { //done
}
}
void Hercules17() { //done
void Stars::Hercules17() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -610,7 +611,7 @@ void Hercules17() { //done
}
void Cygnus18() { //done
void Stars::Cygnus18() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -642,7 +643,7 @@ void Cygnus18() { //done
}
void Pavo19() { //done
void Stars::Pavo19() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -674,7 +675,7 @@ void Pavo19() { //done
}
void Centaurus20() { //done
void Stars::Centaurus20() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -715,7 +716,7 @@ void Centaurus20() { //done
}
void CanesVenatici21() { //done
void Stars::CanesVenatici21() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -741,7 +742,7 @@ void CanesVenatici21() { //done
}
void Lynx22() { //done
void Stars::Lynx22() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -771,7 +772,7 @@ void Lynx22() { //done
}
void Auriga23() { //done
void Stars::Auriga23() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -801,7 +802,7 @@ void Auriga23() { //done
}
void Hydra24() { //done
void Stars::Hydra24() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......@@ -841,7 +842,7 @@ void Hydra24() { //done
}
void Vela25() { //done
void Stars::Vela25() { //done
for(int row = 0; row < 24; row++) {
for(int col = 0; col < 40; col++) {
......
......@@ -30,7 +30,6 @@ class Stars {
void Pisces14();
void UrsaMinor15();
void UrsaMajor16();
//// new
void Hercules17();
void Cygnus18();
void Pavo19();
......
/***************
* Made by Elon Bontemps
* ***************/
#include "countries.h"
#include <iostream> //make a function
#include <utility>
#include <string>
#include <map>
#include <fstream>
#include <vector>
using namespace std;
......
......@@ -9,73 +9,50 @@
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 <double,double> AltAndAziPair;
pair <double, double> longAndLatPair;
vector <pair<double,double>> window;
vector <pair<double,double>> 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<double, double> test;
// test.first = -46;
// test.second = 89;
// pair<double,double> horizontal;
// horizontal.first = 20;
// horizontal.second = 270;
hoursSinceYear = dateToHour(monthInput, yearInput, monthDay, hourInput, minuteInput);
do{
//variables
string monthInput;
int monthDay = 0;
int yearInput = 0;
int hourInput = 0;
int minuteInput = 0;
double hoursSinceYear = 0;
pair <double,double> AltAndAziPair;
pair <double, double> longAndLatPair;
pair<double,double> 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();
vector <pair<double,double>> window;
vector <pair<double,double>> coordinates;
printConstellation(coordinates, window);
cout << "==============Welcome to the Star-Gazer v 1.0==============" << endl;
yearInput = yearPrompt();
} while (true);
//cout << dateToHour(yearInput, monthInput, monthDay, hourInput, minuteInput) << endl;
monthInput = monthPrompt();
monthDay = dayPrompt(monthInput, yearInput);
hourInput = hourPrompt();
minuteInput = minutePrompt();
AltAndAziPair = altAndAziPair ();
printCities();