Functions.cpp 29.8 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 26 27 28 29 30 31 32 33 34 35
    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)) {
            cout << "This is not a leap yar." << endl;
        }
        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 39 40 41 42 43 44 45 46 47 48
    do {
        cout << "Enter month: ";
        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;
}

Walterio Montanez's avatar
Walterio Montanez committed
178
double dateToHour (string month, int year, 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 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
    vector <pair<double, double>> coordinates;
    // Canis Major
    pair<double, double> pair1a;
    pair1a = make_pair(7.45, -9.0);
    coordinates.push_back(pair1a);
    pair<double, double> pair1b;
    pair1b = make_pair(6.1, -9.0);
    coordinates.push_back(pair1b);
    pair<double, double> pair1c;
    pair1c = make_pair(7.45, -33.0);
    coordinates.push_back(pair1c);
    pair<double, double> pair1d;
    pair1d = make_pair(6.1, -33.0);
    coordinates.push_back(pair1d);
    
    //Eridanius
    pair<double, double> pair2a;
    pair2a = make_pair(5.1, -.3);
    coordinates.push_back(pair2a);
    pair<double, double> pair2b;
    pair2b = make_pair(1.6, -.3);
    coordinates.push_back(pair2b);
    pair<double, double> pair2c;
    pair2c = make_pair(5.1, -59.0);
    coordinates.push_back(pair2c);
    pair<double, double> pair2d;
    pair2d = make_pair(1.6, -59.0);
    coordinates.push_back(pair2d);
    
    // Gemini
    pair<double, double> pair3a;
    pair3a = make_pair(8.1, 35.0);
    coordinates.push_back(pair3a);
    pair<double, double> pair3b;
    pair3b = make_pair(6.1, 35.0);
    coordinates.push_back(pair3b);
    pair<double, double> pair3c;
    pair3c = make_pair(8.1, 10.1);
    coordinates.push_back(pair3c);
    pair<double, double> pair3d;
    pair3d = make_pair(6.1, 10.1);
    coordinates.push_back(pair3d);
    
    // Orion
    pair<double, double> pair4a;
    pair4a = make_pair(6.3, 25.0);
    coordinates.push_back(pair4a);
    pair<double, double> pair4b;
    pair4b = make_pair(4.7, 25.0);
    coordinates.push_back(pair4b);
    pair<double, double> pair4c;
    pair4c = make_pair(6.3, -10.0);
    coordinates.push_back(pair4c);
    pair<double, double> pair4d;
    pair4d = make_pair(4.7, -10.0);
    coordinates.push_back(pair4d);
    
    // Tarus
    pair<double, double> pair5a;
    pair5a = make_pair(6.7, 30.0);
    coordinates.push_back(pair5a);
    pair<double, double> pair5b;
    pair5b = make_pair(3.5, 30.0);
    coordinates.push_back(pair5b);
    pair<double, double> pair5c;
    pair5c = make_pair(6.7, 0);
    coordinates.push_back(pair5c);
    pair<double, double> pair5d;
    pair5d = make_pair(3.5, 0);
    coordinates.push_back(pair5d);
    
    // Bootes
    pair<double, double> pair6a;
    pair6a = make_pair(16.4, 53.0);
    coordinates.push_back(pair6a);
    pair<double, double> pair6b;
    pair6b = make_pair(13.8, 53.0);
    coordinates.push_back(pair6b);
    pair<double, double> pair6c;
    pair6c = make_pair(16.4, 7.0);
    coordinates.push_back(pair6c);
    pair<double, double> pair6d;
    pair6d = make_pair(13.8, 7.0);
    coordinates.push_back(pair6d);
    
    // Cancer
    pair<double, double> pair7a;
    pair7a = make_pair(9.5, 35.0);
    coordinates.push_back(pair7a);
    pair<double, double> pair7b;
    pair7b = make_pair(7.9, 35.0);
    coordinates.push_back(pair7b);
    pair<double, double> pair7c;
    pair7c = make_pair(9.5, 5.0);
    coordinates.push_back(pair7c);
    pair<double, double> pair7d;
    pair7d = make_pair(7.9, 5.0);
    coordinates.push_back(pair7d);
    
    // Leo
    pair<double, double> pair8a;
Brandon Reid's avatar
Brandon Reid committed
543
    pair8a = make_pair(12.1, 32.0);
Brandon Reid's avatar
Brandon Reid committed
544 545
    coordinates.push_back(pair8a);
    pair<double, double> pair8b;
Brandon Reid's avatar
Brandon Reid committed
546
    pair8b = make_pair(9.5, 32.0);
Brandon Reid's avatar
Brandon Reid committed
547 548
    coordinates.push_back(pair8b);
    pair<double, double> pair8c;
Brandon Reid's avatar
Brandon Reid committed
549
    pair8c = make_pair(12.1, 7.0);
Brandon Reid's avatar
Brandon Reid committed
550 551
    coordinates.push_back(pair8c);
    pair<double, double> pair8d;
Brandon Reid's avatar
Brandon Reid committed
552
    pair8d = make_pair(9.5, 7.0);
Brandon Reid's avatar
Brandon Reid committed
553
    coordinates.push_back(pair8d);
Brandon Reid's avatar
Brandon Reid committed
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
    
    // Virgo
    pair<double, double> pair9a;
    pair9a = make_pair(15.0, 9.0);
    coordinates.push_back(pair9a);
    pair<double, double> pair9b;
    pair9b = make_pair(12.0, 9.0);
    coordinates.push_back(pair9b);
    pair<double, double> pair9c;
    pair9c = make_pair(15.0, -12.0);
    coordinates.push_back(pair9c);
    pair<double, double> pair9d;
    pair9d = make_pair(12.0, -12.0);
    coordinates.push_back(pair9d);
    
    // Aquila
    pair<double, double> pair10a;
    pair10a = make_pair(20.3, 13.0);
    coordinates.push_back(pair10a);
    pair<double, double> pair10b;
    pair10b = make_pair(19.0, 13.0);
    coordinates.push_back(pair10b);
    pair<double, double> pair10c;
    pair10c = make_pair(20.3, -5.0);
    coordinates.push_back(pair10c);
    pair<double, double> pair10d;
    pair10d = make_pair(19.0, 13.0);
    coordinates.push_back(pair10d);
    
    // Sagitarius
    pair<double, double> pair11a;
    pair11a = make_pair(20.0, -20.0);
    coordinates.push_back(pair11a);
    pair<double, double> pair11b;
    pair11b = make_pair(18.0, -20.0);
    coordinates.push_back(pair11b);
    pair<double, double> pair11c;
    pair11c = make_pair(20.0, -44.4);
    coordinates.push_back(pair11c);
    pair<double, double> pair11d;
    pair11d = make_pair(18.0, -44.4);
    coordinates.push_back(pair11d);
    
    // Scorpius
    pair<double, double> pair12a;
    pair12a = make_pair(18.0, -21.1);
    coordinates.push_back(pair12a);
    pair<double, double> pair12b;
    pair12b = make_pair(16.0, -21.0);
    coordinates.push_back(pair12b);
    pair<double, double> pair12c;
    pair12c = make_pair(18.0, -42.0);
    coordinates.push_back(pair12c);
Brandon Reid's avatar
Brandon Reid committed
607
    pair<double, double> pair12d;
Brandon Reid's avatar
Brandon Reid committed
608 609 610 611 612 613 614 615 616 617
    pair12d = make_pair(16.0, -42.0);
    coordinates.push_back(pair12d);
    
    // Capricornus
    pair<double, double> pair13a;
    pair13a = make_pair(21.8, -12.0);
    coordinates.push_back(pair13a);
    pair<double, double> pair13b;
    pair13b = make_pair(20.3, -12.0);
    coordinates.push_back(pair13b);
Brandon Reid's avatar
Brandon Reid committed
618
    pair<double, double> pair13c;
Brandon Reid's avatar
Brandon Reid committed
619 620 621 622 623 624 625 626 627 628 629 630 631
    pair13c = make_pair(21.8, -28.0);
    coordinates.push_back(pair13c);
    pair<double, double> pair13d;
    pair13d = make_pair(20.3, -28.0);
    coordinates.push_back(pair13d);
    
    // Pegasus
    pair<double, double> pair14a;
    pair14a = make_pair(.2, 30.0);
    coordinates.push_back(pair14a);
    pair<double, double> pair14b;
    pair14b = make_pair(21.2, 30.0);
    coordinates.push_back(pair14b);
Brandon Reid's avatar
Brandon Reid committed
632
    pair<double, double> pair14c;
Brandon Reid's avatar
Brandon Reid committed
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
    pair14c = make_pair(.2, 6.0);
    coordinates.push_back(pair14c);
    pair<double, double> pair14d;
    pair14d = make_pair(21.2, 6.0);
    coordinates.push_back(pair14d);
    
    // Pisces
    pair<double, double> pair15a;
    pair15a = make_pair(2.0, 31.0);
    coordinates.push_back(pair15a);
    pair<double, double> pair15b;
    pair15b = make_pair(23.1, 31.0);
    coordinates.push_back(pair15b);
    pair<double, double> pair15c;
    pair15c = make_pair(2.0, 2.0);
    coordinates.push_back(pair15c);
    pair<double, double> pair15d;
    pair15d = make_pair(23.1, 2.0);
    coordinates.push_back(pair15d);
    
    // Ursa Minor
    pair<double, double> pair16a;
    pair16a = make_pair(2.5, 89.0);
    coordinates.push_back(pair16a);
    pair<double, double> pair16b;
    pair16b = make_pair(15.0, 89.0);
    coordinates.push_back(pair16b);
    pair<double, double> pair16c;
    pair16c = make_pair(2.5, 70.0);
    coordinates.push_back(pair16c);
    pair<double, double> pair16d;
    pair16d = make_pair(15.0, 70.0);
    coordinates.push_back(pair16d);
    
    // Ursa Major
    pair<double, double> pair17a;
    pair17a = make_pair(13.7, 61.0);
    coordinates.push_back(pair17a);
    pair<double, double> pair17b;
    pair17b = make_pair(8.6, 61.0);
    coordinates.push_back(pair17b);
Brandon Reid's avatar
Brandon Reid committed
674
    pair<double, double> pair17c;
Brandon Reid's avatar
Brandon Reid committed
675 676
    pair17c = make_pair(13.7, 32.0);
    coordinates.push_back(pair17c);
Brandon Reid's avatar
Brandon Reid committed
677
    pair<double, double> pair17d;
Brandon Reid's avatar
Brandon Reid committed
678 679
    pair17d = make_pair(8.6, 32.0);
    coordinates.push_back(pair17d);
Brandon Reid's avatar
Brandon Reid committed
680
}
Brandon Reid's avatar
Brandon Reid committed
681

Walterio Montanez's avatar
Walterio Montanez committed
682

Brandon Reid's avatar
Brandon Reid committed
683
void printConstellation (vector <pair<double,double>> constellationCoordinates, vector <pair<double,double>> window) {
Brandon Reid's avatar
Brandon Reid committed
684 685
    int inrangeCount = 0;
    int coordinateCount = 0;
Walterio Montanez's avatar
Walterio Montanez committed
686
    
Brandon Reid's avatar
Brandon Reid committed
687
    for(int j = 0; j < (constellationCoordinates.size() / 4); j++) {
Brandon Reid's avatar
Brandon Reid committed
688 689 690
        inrangeCount = 0;
        for (int i = 0; i < 4; i++) {
            coordinateCount++;
Brandon Reid's avatar
Brandon Reid committed
691 692 693 694
            if(((window.at(0).first) > (constellationCoordinates.at(coordinateCount).first)) && ((window.at(1).first) < (constellationCoordinates.at(coordinateCount).first))
            && ((window.at(2).first) > (constellationCoordinates.at(coordinateCount).first)) && ((window.at(3).first) < (constellationCoordinates.at(coordinateCount).first))
            && ((window.at(0).second) > (constellationCoordinates.at(coordinateCount).second)) && ((window.at(1).second) < (constellationCoordinates.at(coordinateCount).second))
            && ((window.at(2).second) > (constellationCoordinates.at(coordinateCount).second)) && ((window.at(3).second) < (constellationCoordinates.at(coordinateCount).second))) {
Brandon Reid's avatar
Brandon Reid committed
695 696 697 698 699 700 701
                inrangeCount++;
            }
        }
        if (inrangeCount == 4) {
            cout << "Constellation" << constellationNamer(coordinateCount) << "is fully in view." << endl
                 << "Here is an image." << endl;
            constellationOutputter(coordinateCount);
Brandon Reid's avatar
Brandon Reid committed
702
        } else if (inrangeCount < 4 && inrangeCount > 0) {
Brandon Reid's avatar
Brandon Reid committed
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775
            cout << "Constellation" << constellationNamer(coordinateCount) << "is partially in view." << endl
                 << "Here is an image." << endl;
            constellationOutputter(coordinateCount);
        } else {
            cout << endl;
        }
    }
    
}

string constellationNamer (int index) {
    if (index == 3) {
        return " Canis Major ";
    } else if (index == 7) {
        return " Eridanius ";
    } else if (index == 11) {
        return " Gemini ";
    } else if (index == 15) {
        return " Orion ";
    } else if (index == 19) {
        return  " Tarus ";
    } else if (index == 23) {
        return " Bootes ";
    } else if (index == 27) {
        return " Cancer";
    } else if (index == 31) {
        return " Leo ";
    } else if (index == 35) {
        return  " Virgo ";
    } else if (index == 39) {
        return " Aquila ";
    } else if (index == 43) {
        return " Sagitarius ";
    } else if (index == 47) {
        return " Scorpius ";
    } else if (index == 51) {
        return " Capricornus ";
    } else if (index == 55) {
        return  " Pegasus ";
    } else if (index == 59) {
        return " Pisces ";
    } else if (index == 63) {
        return " Ursa Minor ";
    } else if (index == 67) {
        return " Ursa Major ";
    }
}

void constellationOutputter (int index) {
    Stars a;
     if (index == 3) {
        a.CanisMajor0();
    } else if (index == 7) {
        a.Eridanius1();
    } else if (index == 11) {
        a.Gemini2();
    } else if (index == 15) {
        a.Orion3();
    } else if (index == 19) {
        a.Tarus4();
    } else if (index == 23) {
        a.Bootes5();
    } else if (index == 27) {
        a.Cancer6();
    } else if (index == 31) {
        a.Leo7();
    } else if (index == 35) {
        a.Virgo8();
    } else if (index == 39) {
        a.Aquila9();
    } else if (index == 43) {
        a.Sagistarius10();
    } else if (index == 47) {
Brandon Reid's avatar
Brandon Reid committed
776
        a.Scorpius11();
Brandon Reid's avatar
Brandon Reid committed
777 778 779 780 781
    } else if (index == 51) {
        a.Capricornus12();
    } else if (index == 55) {
        a.Pegasus13();
    } else if (index == 59) {
Brandon Reid's avatar
Brandon Reid committed
782
        a.Pisces14();
Brandon Reid's avatar
Brandon Reid committed
783 784 785 786
    } else if (index == 63) {
        a.UrsaMinor15();
    } else if (index == 67) {
        a.UrsaMajor16();
Walterio Montanez's avatar
Walterio Montanez committed
787 788
    }
}