Functions.cpp 26.7 KB
Newer Older
Elon Bontemps's avatar
Elon Bontemps committed
1
#include "Functions.h"
Brandon Reid's avatar
Brandon Reid committed
2
#include "Stars.h"
Elon Bontemps's avatar
Elon Bontemps committed
3 4 5 6 7
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
Brandon Reid's avatar
Brandon Reid committed
8
#include <utility>
Elon Bontemps's avatar
Elon Bontemps committed
9 10 11 12

using namespace std;

// Input checking functions
Brandon Reid's avatar
Brandon Reid committed
13 14
int yearPrompt () { // empty argument
    int year = 0;
Elon Bontemps's avatar
Elon Bontemps committed
15 16 17 18 19 20 21 22 23 24 25
    do {
        cout << "Enter year: ";
        if (!(cin >> year)) { // validates that numbers were entered and checks input
            cerr << "Error! Please enter a valid integar." << endl;
            cin.clear();
            cin.ignore(1000, '\n');
            continue; 
        }
        if (isLeap(year)) { // Tells user if it is a leap year of not
            cout << "This is a leap year." << endl;
        } else if (!isLeap(year)) {
Brandon Reid's avatar
Brandon Reid committed
26
            cout << "This is not a leap year." << endl;
Elon Bontemps's avatar
Elon Bontemps committed
27 28 29 30 31 32 33 34 35
        }
        if (year > 0 && year < 9099) {
            return year;
        } else {
            cerr << "Error! Invalid year. Please enter a year between 1 and 9099" << endl;
        }
    } while (true);
}

Brandon Reid's avatar
Brandon Reid committed
36 37
string monthPrompt () {
    string month;
Elon Bontemps's avatar
Elon Bontemps committed
38
    do {
Brandon Reid's avatar
Brandon Reid committed
39
        cout << "Enter month (ex.April, May): ";
Elon Bontemps's avatar
Elon Bontemps committed
40 41 42 43 44 45 46 47 48
        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;
        } else {
            cerr << "Error! Please enter a valid month." << endl;
        }
    } while (true);
}

Brandon Reid's avatar
Brandon Reid committed
49 50
int dayPrompt (string month, int year) {
    int day = 0;
Elon Bontemps's avatar
Elon Bontemps committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    do {
        cout << "Enter day: ";
        if (!(cin >> day)) { // validates that numbers were entered and checks input
            cerr << "Error! Please enter a valid integar." << endl;
            cin.clear();
            cin.ignore(1000, '\n');
            continue; 
        }
        if (month == "January" || month == "March" || month == "May" || month == "July" || month == "August" || month == "October" || month == "December") {
            if (day > 0 && day <= 31) {
                return day;
            }
        }
        if (month == "April" || month == "June" || month == "September" || month == "November") {
            if (day > 0 && day <= 30) {
                return day;
            }
        }
        if (month == "February") {
            if (isLeap(year)) {
                if (day > 0 && day <= 29) {
                    return day;
                } 
            } else if (!isLeap(year)) {
                if (day > 0 && day <= 28) {
                    return day;
                }
            }
        }
        cerr << "Error! Please enter a valid date." << endl;
    } while (true);
}

Brandon Reid's avatar
Brandon Reid committed
84 85
int hourPrompt () {
    int hour = 0;
Elon Bontemps's avatar
Elon Bontemps committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    do {
        cout << "Enter hour (0 - 23): ";
        if (!(cin >> hour)) { // validates that numbers were entered and checks input
            cerr << "Error! Please enter a valid integar." << endl;
            cin.clear();
            cin.ignore(1000, '\n');
            continue; 
        }
        if (hour >= 0 && hour < 24) {
            return hour;
        } else {
            cerr << "Error! Please enter a valid hour." << endl;
        }
    } while (true);
}

Brandon Reid's avatar
Brandon Reid committed
102 103
int minutePrompt () {
    int minute = 0;
Elon Bontemps's avatar
Elon Bontemps committed
104 105
    do {
        cout <<  "Enter minute: ";
Elon Bontemps's avatar
Elon Bontemps committed
106
        if (!(cin >> minute)) { // validates that numbers were entered and checks input 
Elon Bontemps's avatar
Elon Bontemps committed
107 108 109 110 111 112 113 114 115 116 117 118 119
            cerr << "Error! Please enter a valid integar." << endl;
            cin.clear();
            cin.ignore(1000, '\n');
            continue; 
        }
        if (minute >= 0 && minute < 60) {
            return minute;
        } else {
            cerr << "Error! Please enter a valid minute." << endl;
        }
    } while (true);
}

Brandon Reid's avatar
Brandon Reid committed
120 121
pair<double,double> altAndAziPair () {
    double altitude = 0;
Elon Bontemps's avatar
Elon Bontemps committed
122
    double Azi;
Brandon Reid's avatar
Brandon Reid committed
123
    string direction;
Elon Bontemps's avatar
Elon Bontemps committed
124 125 126
    pair<double,double> aziPair;
    do {
        cout <<  "Enter the altitude at which you are looking (0-90): ";
Brandon Reid's avatar
Brandon Reid committed
127 128 129 130 131 132 133 134 135 136 137
        if (!(cin >> altitude)) { // validates that numbers were entered and checks input
            cerr << "Error! Please enter a valid integer." << endl;
            cin.clear();
            cin.ignore(1000, '\n');
            continue; 
        } 
        if (altitude >= 0 && altitude <= 90) {
            break;
        } else {
            cerr << "Please put in a valid value." << endl;
        }
Brandon Reid's avatar
Brandon Reid committed
138
    } while (true);
Elon Bontemps's avatar
Elon Bontemps committed
139
    
Brandon Reid's avatar
Brandon Reid committed
140
    do { // Prompt and check for cardinal direction
Elon Bontemps's avatar
Elon Bontemps committed
141
        cout <<  "Enter a cardinal direction (North, South, East, West, Northeast, Southeast, Southwest, or Northwest): ";
Brandon Reid's avatar
Brandon Reid committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
        cin >> direction;

        if (direction == "North") {
            Azi = 0;
            break;
        } else if (direction == "South") {
            Azi = 180;
            break;
        } else if (direction == "East") {
            Azi = 90;
            break;
        } else if (direction == "West") {
            Azi = 270;
            break;
        } else if (direction == "Northeast") {
            Azi = 45;
            break;
        } else if (direction == "Southeast") {
            Azi = 135;
            break;
        } else if (direction == "Southwest") {
            Azi = 225;
            break;
        } else if (direction == "Northwest") {
            Azi = 315;
            break;
        } else {
            cerr << "Error! Please input a valid direction" << endl;
Elon Bontemps's avatar
Elon Bontemps committed
170
        }
Brandon Reid's avatar
Brandon Reid committed
171
    } while (true);
Elon Bontemps's avatar
Elon Bontemps committed
172 173 174 175 176 177
    
    aziPair = make_pair(altitude,Azi);
    
    return aziPair;
}

Brandon Reid's avatar
Brandon Reid committed
178
double dateToHour (string month, int day, int hour, int minute) { // Converts the date into hours 
Elon Bontemps's avatar
Elon Bontemps committed
179 180 181 182
    //variables
    double totHours = 0;
    int monthNum = 0;
    
Walterio Montanez's avatar
Walterio Montanez committed
183
    if (month == "January") { // For the number of months before each month in order
Walterio Montanez's avatar
Walterio Montanez committed
184
        monthNum = 0;
Elon Bontemps's avatar
Elon Bontemps committed
185
    } else if (month == "February") {
Walterio Montanez's avatar
Walterio Montanez committed
186
        monthNum = 1;
Elon Bontemps's avatar
Elon Bontemps committed
187
    } else if (month == "March") {
Walterio Montanez's avatar
Walterio Montanez committed
188
        monthNum = 2;
Elon Bontemps's avatar
Elon Bontemps committed
189
    } else if (month == "April") {
Walterio Montanez's avatar
Walterio Montanez committed
190
        monthNum = 3;
Elon Bontemps's avatar
Elon Bontemps committed
191
    } else if (month == "May") {
Walterio Montanez's avatar
Walterio Montanez committed
192
        monthNum = 4;
Elon Bontemps's avatar
Elon Bontemps committed
193
    } else if (month == "June") {
Walterio Montanez's avatar
Walterio Montanez committed
194
        monthNum = 5;
Elon Bontemps's avatar
Elon Bontemps committed
195
    } else if (month == "July") {
Walterio Montanez's avatar
Walterio Montanez committed
196
        monthNum = 6;
Elon Bontemps's avatar
Elon Bontemps committed
197
    } else if (month == "August") {
Walterio Montanez's avatar
Walterio Montanez committed
198
        monthNum = 7;
Elon Bontemps's avatar
Elon Bontemps committed
199
    } else if (month == "September") {
Walterio Montanez's avatar
Walterio Montanez committed
200
        monthNum = 8;
Elon Bontemps's avatar
Elon Bontemps committed
201
    } else if (month == "October") {
Walterio Montanez's avatar
Walterio Montanez committed
202
        monthNum = 9;
Elon Bontemps's avatar
Elon Bontemps committed
203
    } else if (month == "November") {
Walterio Montanez's avatar
Walterio Montanez committed
204
        monthNum = 10;
Elon Bontemps's avatar
Elon Bontemps committed
205
    } else {
Walterio Montanez's avatar
Walterio Montanez committed
206
        monthNum = 11;
Elon Bontemps's avatar
Elon Bontemps committed
207
    }
Walterio Montanez's avatar
Walterio Montanez committed
208
    if (month == "January" || month == "March" || month == "May" || month == "July" || month == "August" || month == "October" || month == "December") { //Calculates the amount of hours for the months with 31 days
Walterio Montanez's avatar
Walterio Montanez committed
209 210
        totHours = (monthNum * 744) + ((day - 1) * 24) + (hour - 1) + (minute / 60);
        }
Walterio Montanez's avatar
Walterio Montanez committed
211
    else if (month == "April" || month == "June" || month == "September" || month == "November") { // Calculates the hours for the months with 30 days
Walterio Montanez's avatar
Walterio Montanez committed
212 213
        totHours = (monthNum * 720) + ((day - 1) * 24) + (hour - 1) + (minute / 60);
    }
Walterio Montanez's avatar
Walterio Montanez committed
214 215 216 217 218
    else if (month == "February") {
        if (isLeap(year)) { // Takes leap year into consideration and calculates the days in February with 29 days
            totHours = (monthNum * 696) + ((day - 1) * 24) + (hour - 1) + (minute / 60);
        } else if (!isLeap(year)) { // Calculates when February has 28 days
            totHours = (monthNum * 672) + ((day - 1) * 24) + (hour - 1) + (minute / 60);
Walterio Montanez's avatar
Walterio Montanez committed
219
        }
Elon Bontemps's avatar
Elon Bontemps committed
220 221 222 223
    }
    return totHours;
}

Brandon Reid's avatar
Brandon Reid committed
224
bool isLeap (int year) { // bool check for leap years
Elon Bontemps's avatar
Elon Bontemps committed
225 226 227 228 229
    if ((year % 4) == 0) {
        return true;
    } else {
        return false;
    }
Brandon Reid's avatar
Brandon Reid committed
230 231
}

Brandon Reid's avatar
Brandon Reid committed
232
vector <pair<double, double>> viewFinder (pair <double, double> centerPt) { // function that finds the coordinates the corner points of a viewing window
Brandon Reid's avatar
Brandon Reid committed
233
    // variables
Brandon Reid's avatar
Brandon Reid committed
234
    vector <pair<double, double>> corners;
Brandon Reid's avatar
Brandon Reid committed
235 236 237 238 239
    pair<double, double> pair1;
    pair<double, double> pair2;
    pair<double, double> pair3;
    pair<double, double> pair4;

Brandon Reid's avatar
Brandon Reid committed
240
    if (centerPt.second > 0) {
Brandon Reid's avatar
Brandon Reid committed
241
        if (centerPt.first > 20.125 && centerPt.second < 51) { 
Brandon Reid's avatar
Brandon Reid committed
242 243 244 245 246
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair((centerPt.first + 3.875) - 24,  centerPt.second + 39); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
Brandon Reid's avatar
Brandon Reid committed
247
                    pair2 = make_pair((centerPt.first - 3.875),  centerPt.second + 39);
Brandon Reid's avatar
Brandon Reid committed
248 249 250 251 252
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair((centerPt.first + 3.875) - 24,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
Brandon Reid's avatar
Brandon Reid committed
253
                    pair4 = make_pair((centerPt.first - 3.875),  centerPt.second - 39);
Brandon Reid's avatar
Brandon Reid committed
254
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
255
                }
Brandon Reid's avatar
Brandon Reid committed
256
            }
Brandon Reid's avatar
Brandon Reid committed
257
        } else if (centerPt.first < 3.875 && centerPt.second < 51) { 
Brandon Reid's avatar
Brandon Reid committed
258 259
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
Brandon Reid's avatar
Brandon Reid committed
260
                    pair1 = make_pair((centerPt.first + 3.875),  centerPt.second + 39); 
Brandon Reid's avatar
Brandon Reid committed
261 262 263 264 265 266 267 268 269 270
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(24 - (3.875 - centerPt.first),  centerPt.second + 39);
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(24 - (3.875 - centerPt.first),  centerPt.second - 39);
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
271
                }
Brandon Reid's avatar
Brandon Reid committed
272
            }
Brandon Reid's avatar
Brandon Reid committed
273
        } else if (centerPt.first > 20.125 && centerPt.second > 51) { 
Brandon Reid's avatar
Brandon Reid committed
274 275 276 277 278 279 280 281 282 283 284 285 286
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair((centerPt.first + 3.875) - 24,  -90 + (centerPt.second - 51)); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(centerPt.first - 3.875,  -90 + (centerPt.second - 51));
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair((centerPt.first + 3.875) - 24,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(centerPt.first - 3.875,  centerPt.second - 39);
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
287
                }
Brandon Reid's avatar
Brandon Reid committed
288
            }
Brandon Reid's avatar
Brandon Reid committed
289
        } else if (centerPt.first < 3.875 && centerPt.second > 51) { 
Brandon Reid's avatar
Brandon Reid committed
290 291 292 293 294 295 296 297 298 299 300 301 302
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair(centerPt.first + 3.875,  -90 + (centerPt.second - 51)); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(24 - (3.875 - centerPt.first),  -90 + (centerPt.second - 51));
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(24 - (3.875 - centerPt.first),  centerPt.second - 39);
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
303
                }
Brandon Reid's avatar
Brandon Reid committed
304
            }
Brandon Reid's avatar
Brandon Reid committed
305
        } else if ((centerPt.first < 20.125 && centerPt.first > 3.875) && centerPt.second > 51) { 
Brandon Reid's avatar
Brandon Reid committed
306 307 308 309 310 311 312 313 314 315 316 317 318
           for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair(centerPt.first + 3.875,  -90 + (centerPt.second - 51)); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(centerPt.first - 3.875,  -90 + (centerPt.second - 51));
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(centerPt.first - 3.875,  centerPt.second - 39);
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
319
                }
Brandon Reid's avatar
Brandon Reid committed
320
            }
Brandon Reid's avatar
Brandon Reid committed
321
        } else if ((centerPt.first < 20.125 && centerPt.first > 3.875) && centerPt.second < 51) { 
Brandon Reid's avatar
Brandon Reid committed
322 323 324 325 326 327 328 329 330 331 332 333 334
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair(centerPt.first + 3.875,  centerPt.second + 39); 
                    corners.push_back(pair2);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(centerPt.first - 3.875,  centerPt.second + 51);
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(centerPt.first - 3.875,  centerPt.second - 39);
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
335 336
                }
            }
Brandon Reid's avatar
Brandon Reid committed
337 338
        }
    } else if (centerPt.second < 0) {
Brandon Reid's avatar
Brandon Reid committed
339
        if (centerPt.first > 20.125 && centerPt.second > -51) { 
Brandon Reid's avatar
Brandon Reid committed
340 341 342 343 344
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair((centerPt.first + 3.875) - 24,  centerPt.second + 39); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
Brandon Reid's avatar
Brandon Reid committed
345
                    pair2 = make_pair((centerPt.first - 3.875),  centerPt.second + 39);
Brandon Reid's avatar
Brandon Reid committed
346 347 348 349 350
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair((centerPt.first + 3.875) - 24,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
Brandon Reid's avatar
Brandon Reid committed
351
                    pair4 = make_pair((centerPt.first - 3.875),  centerPt.second - 39);
Brandon Reid's avatar
Brandon Reid committed
352
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
353
                }
Brandon Reid's avatar
Brandon Reid committed
354
            }
Brandon Reid's avatar
Brandon Reid committed
355
        } else if (centerPt.first < 3.875 && centerPt.second > -51) { 
Brandon Reid's avatar
Brandon Reid committed
356 357
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
Brandon Reid's avatar
Brandon Reid committed
358
                    pair1 = make_pair((centerPt.first + 3.875),  centerPt.second + 39); 
Brandon Reid's avatar
Brandon Reid committed
359 360 361 362 363 364 365 366 367 368
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(24 - (3.875 - centerPt.first),  centerPt.second + 39);
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875,  centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(24 - (3.875 - centerPt.first),  centerPt.second - 39);
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
369
                }
Brandon Reid's avatar
Brandon Reid committed
370
            }
Brandon Reid's avatar
Brandon Reid committed
371
        } else if (centerPt.first > 20.125 && centerPt.second < -51) { 
Brandon Reid's avatar
Brandon Reid committed
372 373 374 375 376 377 378 379 380 381 382 383 384
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair((centerPt.first + 3.875) - 24,  centerPt.second + 39); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(centerPt.first - 3.875,  centerPt.second + 39);
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair((centerPt.first + 3.875) - 24,  90 + (centerPt.second + 51)); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(centerPt.first - 3.875,  90 + (centerPt.second + 51));
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
385
                }
Brandon Reid's avatar
Brandon Reid committed
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
            }
        } else if (centerPt.first < 3.875 && centerPt.second < -51) {
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair(centerPt.first + 3.875,  centerPt.second + 39); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(24 - (3.875 - centerPt.first), centerPt.second + 39);
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875, 90 + (centerPt.second + 51)); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(24 - (3.875 - centerPt.first), 90 + (centerPt.second + 51));
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
401
                }
Brandon Reid's avatar
Brandon Reid committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
            }
        } else if ((centerPt.first < 20.125 && centerPt.first > 3.875) && centerPt.second < -51) {
            for(int i = 0; i < 4; i++) {
                if (i == 0) { // top left point
                    pair1 = make_pair(centerPt.first + 3.875, centerPt.second + 39); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(centerPt.first - 3.875, centerPt.second + 39);
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875, 90 + (centerPt.second + 51)); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(centerPt.first - 3.875, 90 + (centerPt.second + 51));
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
417
                }
Brandon Reid's avatar
Brandon Reid committed
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
            }
        } else if ((centerPt.first < 20.125 && centerPt.first > 3.875) && centerPt.second > -51) {
            for(int i = 0; i < 4; i++) {
                pair<double, double> pair;
                if (i == 0) { // top left point
                    pair1 = make_pair(centerPt.first + 3.875, centerPt.second + 39); 
                    corners.push_back(pair1);   
                } else if (i == 1) { // top right point
                    pair2 = make_pair(centerPt.first - 3.875, centerPt.second + 39);
                    corners.push_back(pair2);   
                } else if (i == 2) { // bottom left point
                    pair3 = make_pair(centerPt.first + 3.875, centerPt.second - 39); 
                    corners.push_back(pair3);   
                } else if (i == 3) { // bottom right point
                    pair4 = make_pair(centerPt.first - 3.875, centerPt.second - 39);
                    corners.push_back(pair4);   
Brandon Reid's avatar
Brandon Reid committed
434 435 436
                }
            }
        }
Brandon Reid's avatar
Brandon Reid committed
437
    }
Brandon Reid's avatar
Brandon Reid committed
438
    return corners;
Brandon Reid's avatar
Brandon Reid committed
439 440
}

Brandon Reid's avatar
Brandon Reid committed
441
vector <pair<double, double>> constellationCoordinates () { // Function to store the coordinates of the constellations
Brandon Reid's avatar
Brandon Reid committed
442 443
    vector <pair<double, double>> coordinates;
    // Canis Major
Brandon Reid's avatar
Brandon Reid committed
444 445 446 447
    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));
Brandon Reid's avatar
Brandon Reid committed
448 449
    
    //Eridanius
Walterio Montanez's avatar
Walterio Montanez committed
450 451
    coordinates.push_back(make_pair(5.1, -0.3));
    coordinates.push_back(make_pair(1.6, -0.3));
Walterio Montanez's avatar
Walterio Montanez committed
452 453
    coordinates.push_back(make_pair(5.1, -59.0));
    coordinates.push_back(make_pair(1.6, -59.0));
Brandon Reid's avatar
Brandon Reid committed
454 455
    
    // Gemini
Walterio Montanez's avatar
Walterio Montanez committed
456 457 458 459
    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));
Brandon Reid's avatar
Brandon Reid committed
460 461
    
    // Orion
Walterio Montanez's avatar
Walterio Montanez committed
462 463 464 465
    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));
Brandon Reid's avatar
Brandon Reid committed
466 467
    
    // Tarus
Walterio Montanez's avatar
Walterio Montanez committed
468 469 470 471
    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));
Brandon Reid's avatar
Brandon Reid committed
472 473
    
    // Bootes
Walterio Montanez's avatar
Walterio Montanez committed
474 475 476 477 478

    coordinates.push_back(make_pair(16.4, 53.0));
    coordinates.push_back(make_pair(13.8, 53.0));
    coordinates.push_back(make_pair(16.4, 7.0));
    coordinates.push_back(make_pair(13.8, 7.0));
Brandon Reid's avatar
Brandon Reid committed
479 480
    
    // Cancer
Walterio Montanez's avatar
Walterio Montanez committed
481 482 483 484
    coordinates.push_back(make_pair(9.5, 35.0));
    coordinates.push_back(make_pair(7.9, 35.0));
    coordinates.push_back(make_pair(9.5, 5.0));
    coordinates.push_back(make_pair(7.9, 5.0));
Brandon Reid's avatar
Brandon Reid committed
485 486
    
    // Leo
Walterio Montanez's avatar
Walterio Montanez committed
487 488 489 490
    coordinates.push_back(make_pair(12.1, 32.0));
    coordinates.push_back(make_pair(9.5, 32.0));
    coordinates.push_back(make_pair(12.1, 7.0));
    coordinates.push_back(make_pair(9.5, 7.0));
Brandon Reid's avatar
Brandon Reid committed
491 492
    
    // Virgo
Walterio Montanez's avatar
Walterio Montanez committed
493 494 495 496
    coordinates.push_back(make_pair(15.0, 9.0));
    coordinates.push_back(make_pair(12.0, 9.0));
    coordinates.push_back(make_pair(15.0, -12.0));
    coordinates.push_back(make_pair(12.0, -12.0));
Brandon Reid's avatar
Brandon Reid committed
497 498
    
    // Aquila
Walterio Montanez's avatar
Walterio Montanez committed
499 500 501 502
    coordinates.push_back(make_pair(20.3, 13.0));
    coordinates.push_back(make_pair(19.0, 13.0));
    coordinates.push_back(make_pair(20.3, -5.0));
    coordinates.push_back(make_pair(19.0, -5.0));
Brandon Reid's avatar
Brandon Reid committed
503 504
    
    // Sagitarius
Walterio Montanez's avatar
Walterio Montanez committed
505 506 507 508
    coordinates.push_back(make_pair(20.0, -20.0));
    coordinates.push_back(make_pair(18.0, -20.0));
    coordinates.push_back(make_pair(20.0, -44.4));
    coordinates.push_back(make_pair(18.0, -44.4));
Brandon Reid's avatar
Brandon Reid committed
509 510
    
    // Scorpius
Walterio Montanez's avatar
Walterio Montanez committed
511 512 513 514
    coordinates.push_back(make_pair(18.0, -21.1));
    coordinates.push_back(make_pair(16.0, -21.0));
    coordinates.push_back(make_pair(18.0, -42.0));
    coordinates.push_back(make_pair(16.0, -42.0));
Brandon Reid's avatar
Brandon Reid committed
515 516
    
    // Capricornus
Walterio Montanez's avatar
Walterio Montanez committed
517 518 519 520
    coordinates.push_back(make_pair(21.8, -12.0));
    coordinates.push_back(make_pair(20.3, -12.0));
    coordinates.push_back(make_pair(21.8, -28.0));
    coordinates.push_back(make_pair(20.3, -28.0));
Brandon Reid's avatar
Brandon Reid committed
521 522
    
    // Pegasus
Walterio Montanez's avatar
Walterio Montanez committed
523
    coordinates.push_back(make_pair(0.2, 30.0));
Walterio Montanez's avatar
Walterio Montanez committed
524
    coordinates.push_back(make_pair(21.2, 30.0));
Walterio Montanez's avatar
Walterio Montanez committed
525
    coordinates.push_back(make_pair(0.2, 6.0));
Walterio Montanez's avatar
Walterio Montanez committed
526
    coordinates.push_back(make_pair(21.2, 6.0));
Brandon Reid's avatar
Brandon Reid committed
527 528
    
    // Pisces
Walterio Montanez's avatar
Walterio Montanez committed
529 530 531 532
    coordinates.push_back(make_pair(2.0, 31.0));
    coordinates.push_back(make_pair(23.1, 31.0));
    coordinates.push_back(make_pair(2.0, 2.0));
    coordinates.push_back(make_pair(23.1, 2.0));
Brandon Reid's avatar
Brandon Reid committed
533 534
    
    // Ursa Minor
Walterio Montanez's avatar
Walterio Montanez committed
535 536 537 538
    coordinates.push_back(make_pair(2.5, 89.0));
    coordinates.push_back(make_pair(15.0, 89.0));
    coordinates.push_back(make_pair(2.5, 70.0));
    coordinates.push_back(make_pair(15.0, 70.0));
Brandon Reid's avatar
Brandon Reid committed
539 540
    
    // Ursa Major
Walterio Montanez's avatar
Walterio Montanez committed
541 542 543 544
    coordinates.push_back(make_pair(13.7, 61.0));
    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));
Brandon Reid's avatar
Brandon Reid committed
545

Brandon Reid's avatar
Brandon Reid committed
546
    return coordinates;
Brandon Reid's avatar
Brandon Reid committed
547
}
Brandon Reid's avatar
Brandon Reid committed
548

Walterio Montanez's avatar
Walterio Montanez committed
549

Brandon Reid's avatar
Brandon Reid committed
550
void printConstellation (vector <pair<double,double>> constellationCoordinates, vector <pair<double,double>> window) {
Brandon Reid's avatar
Brandon Reid committed
551 552 553 554 555
    // variables
    double windowLeft = window.at(0).first;
    double windowRight = window.at(1).first;
    double windowTop = window.at(0).second;
    double windowBottom = window.at(3).second;
Brandon Reid's avatar
Brandon Reid committed
556 557
    int inrangeCount = 0;
    int coordinateCount = 0;
Brandon Reid's avatar
Brandon Reid committed
558 559
    
    for(unsigned int j = 0; j < (constellationCoordinates.size() / 4) - 1; j++) {
Brandon Reid's avatar
Brandon Reid committed
560 561 562
        inrangeCount = 0;
        for (int i = 0; i < 4; i++) {
            coordinateCount++;
Brandon Reid's avatar
Brandon Reid committed
563 564
            if((windowLeft > constellationCoordinates.at(coordinateCount).first) && (constellationCoordinates.at(coordinateCount).first < windowRight) 
            && (windowTop > constellationCoordinates.at(coordinateCount).second) && (constellationCoordinates.at(coordinateCount).second > windowBottom)) {
Brandon Reid's avatar
Brandon Reid committed
565 566 567 568
                inrangeCount++;
            }
        }
        if (inrangeCount == 4) {
Brandon Reid's avatar
Brandon Reid committed
569 570 571 572
            cout << "Constellation" << constellationNamer(coordinateCount - 1) << "is fully in view." << endl
                 << "Here is an image." << endl << "============================================" << endl;
                 
            constellationOutputter(coordinateCount - 1);
Brandon Reid's avatar
Brandon Reid committed
573
        } else if (inrangeCount < 4 && inrangeCount > 0) {
Brandon Reid's avatar
Brandon Reid committed
574 575 576
            cout << "Constellation" << constellationNamer(coordinateCount - 1) << "is partially in view." << endl
                 << "Here is an image." << endl << "============================================" << endl;
            constellationOutputter(coordinateCount - 1);
Brandon Reid's avatar
Brandon Reid committed
577 578 579
        } else {
            cout << endl;
        }
Brandon Reid's avatar
Brandon Reid committed
580
        
Brandon Reid's avatar
Brandon Reid committed
581 582 583 584 585
    }
    
}

string constellationNamer (int index) {
Brandon Reid's avatar
Brandon Reid committed
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
    switch (index) {
        case 3:
            return " Canis Major ";
        case 7:
            return " Eridanius ";
        case 11:
            return " Gemini ";
        case 15:
            return " Orion ";
        case 19:
            return  " Tarus ";
        case 23:
            return " Bootes ";
        case 27:
            return " Cancer";
        case 31:
            return " Leo ";
        case 35:
            return  " Virgo ";
        case 39:
            return " Aquila ";
        case 43:
            return " Sagitarius ";
        case 47:
            return " Scorpius ";
        case 51:
            return " Capricornus ";
        case 55:
            return  " Pegasus ";
        case 59:
            return " Pisces ";
        case 63:
            return " Ursa Minor ";
        case 67:
            return " Ursa Major ";
        default:
            return " Unknown constellation ";
Brandon Reid's avatar
Brandon Reid committed
623 624 625 626 627
    }
}

void constellationOutputter (int index) {
    Stars a;
Brandon Reid's avatar
Brandon Reid committed
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698
    switch (index) {
        case 3:
            a.CanisMajor0();
            cout << endl;
            break;
        case 7:
            a.Eridanius1();
            cout << endl;
            break;
        case 11:
            a.Gemini2();
            cout << endl;
            break;
        case 15:
            a.Orion3();
            cout << endl;
            break;
        case 19:
            a.Tarus4();
            cout << endl;
            break;
        case 23:
            a.Bootes5();
            cout << endl;
            break;
        case 27:
            a.Cancer6();
            cout << endl;
            break;
        case 31:
            a.Leo7();
            cout << endl;
            break;
        case 35:
            a.Virgo8();
            cout << endl;
            break;
        case 39:
            a.Aquila9();
            cout << endl;
            break;
        case 43:
            a.Sagistarius10();
            cout << endl;
            break;
        case 47:
            a.Scorpius11();
            cout << endl;
            break;
        case 51:
            a.Capricornus12();
            cout << endl;
            break;
        case 55:
            a.Pegasus13();
            cout << endl;
            break;
        case 59:
            a.Pisces14();
            cout << endl;
            break;
        case 63:
            a.UrsaMinor15();
            cout << endl;
            break;
        case 67:
            a.UrsaMajor16();
            cout << endl;
            break;
        default:
            cout << endl;
Walterio Montanez's avatar
Walterio Montanez committed
699 700
    }
}