C++ PROGRAMMING Please, I need help with this! 1. Write a program to read the st
ID: 3834847 • Letter: C
Question
C++ PROGRAMMING
Please, I need help with this!
1. Write a program to read the star catalog and print out the RA & DEC of each star (as a decimal value, not as degrees/minutes/seconds)
2. When that’s working, turn it into a function and write a program to print a list of stars that are within some fixed field of view ( +/- 2 degrees in DEC, +/- 3 degrees in RA) of some point in the sky, such as (RA,DEC) of (10 degrees, 0 degrees).
2.a. Have it print out the star number and the star’s RA & DEC
3. When that is working, turn that into a function, and modify it so the camera direction is an input (i.e., so it will work for any RA, but keep the DEC at 0). Write a program using the "read_catalog(...)" function and the "find_stars_in_FOV(...)" function.
4. When that’s working, scale the RA & DEC by the pixels-per-degree of your 6x4 camera and print out the pixel location of where the each star should be
(actually, subtract the camera’s RA angle from the RA first, so you have an angle relative to the center of the camera).
STAR CATALOG:
RA DEC MAG
1 0.0844 0.5031 6.2900
2 0.2966 1.6889 6.1700
3 0.4234 1.9397 5.7700
4 0.4437 0.0497 6.1900
5 0.5924 0.5056 5.9300
6 0.8835 -1.1442 4.7700
7 1.0636 1.3667 6.0400
8 1.2470 0.9739 5.7000
9 1.3301 0.5089 5.8700
10 1.3769 1.7264 6.2000
11 1.3763 0.4497 6.4900
12 1.4409 0.3986 6.4100
13 1.9316 1.8497 6.0100
14 2.0532 0.1283 5.4300
15 2.0634 0.3403 5.9300
16 2.1081 0.0350 6.2800
17 2.1933 -1.8253 5.9300
18 2.3004 1.7578 5.5800
19 2.3657 0.3958 5.2800
20 2.3701 0.8850 5.4200
21 2.4667 1.9608 6.4500
22 2.5126 0.2553 6.0000
23 2.5359 -1.0350 5.3500
24 2.6581 0.3286 4.0700
25 2.6872 0.6958 5.7100
26 3.0773 1.8636 6.0500
27 3.2129 -1.1961 5.0600
28 3.3062 0.9303 5.3800
29 3.6131 0.5878 5.7100
30 3.6146 0.4017 4.2800
31 3.6665 -1.1206 6.1200
32 3.7418 -1.1631 5.2500
33 3.7490 0.2967 5.5500
34 3.8108 0.2278 5.9100
35 4.0256 -1.5497 5.2800
36 4.0435 0.2689 5.3800
37 4.2273 -1.1497 6.4400
38 4.3575 0.0981 5.8600
39 4.4677 1.8586 6.1500
40 4.4756 1.3808 5.5500
41 4.5313 0.0439 4.9100
42 4.6205 0.9983 5.3100
43 4.6631 -1.0528 6.1000
44 4.8988 1.5694 6.6100
45 4.9141 0.4675 5.9900
46 4.9548 -1.0672 6.2300
47 4.9758 1.7142 4.4700
48 5.0306 0.7222 5.9200
49 5.0333 1.6089 6.2400
50 5.0899 1.1775 6.1700
51 5.1676 0.5653 6.1000
52 5.1948 0.5147 6.6700
53 5.1959 1.0369 5.8900
54 5.2254 1.9681 6.0900
55 5.2298 0.5603 6.3200
56 5.2551 -1.4092 6.1500
57 5.2781 1.9472 6.4200
58 5.3264 -1.4122 6.3400
59 5.3588 0.4164 5.6800
60 5.3627 0.3825 4.7300
61 5.3951 0.1597 5.7000
62 5.3976 0.8672 6.1100
63 5.4080 0.8914 5.0800
64 5.4124 1.8464 4.9500
65 5.4253 0.5442 6.5700
66 5.4297 0.5208 6.1600
67 5.4671 1.2983 6.4100
68 5.4986 1.7892 5.7800
69 5.4956 -1.0922 4.7100
70 5.5335 0.2844 6.8500
71 5.5334 0.2992 2.2300
72 5.5448 -1.5919 5.3500
73 5.5520 -1.7183 6.4600
74 5.5587 -1.1561 5.3400
75 5.5660 1.4078 6.5900
76 5.5678 -1.0356 6.2200
77 5.5678 -1.4706 5.9300
78 5.6036 -1.2019 1.7000
79 5.6793 -1.9428 2.0500
80 5.6793 -1.9428 4.2100
81 5.6807 -1.1289 4.9500
82 5.6849 0.3378 5.9300
83 5.7079 1.4747 4.9100
84 5.7192 -1.6131 6.3100
85 5.7764 1.1681 5.9500
86 5.8417 2.0244 5.9800
87 5.8740 1.8550 4.7800
88 5.9123 0.9683 6.0000
89 5.9651 1.2244 6.2200
90 5.9699 0.9942 6.2200
91 5.9734 1.8369 5.9000
92 5.9804 0.5531 5.2200
93 5.9938 -1.4444 6.6300
94 6.0381 1.6944 6.5900
95 6.2595 0.5122 5.6500
96 6.2650 1.1692 6.3700
97 6.2726 1.0803 6.6300
98 6.4218 1.5011 6.6600
99 6.4212 0.9461 5.8700
100 6.4443 -1.5072 5.8700
101 6.4496 0.8408 6.7100
102 6.4538 0.2992 5.2000
103 6.4543 0.2761 5.5500
104 6.4713 1.9122 6.4800
105 6.5605 -1.2203 5.1000
106 6.5877 0.8900 5.8000
107 6.6439 1.6136 6.2100
108 6.6848 0.4953 5.7900
109 6.8053 -1.3192 5.7500
110 6.8177 1.0019 6.1500
111 6.8472 0.5408 5.7700
112 6.9068 -1.1269 5.4500
113 6.9117 -1.7564 6.2100
114 7.0314 -1.3456 6.1700
115 7.0723 1.4883 6.5700
116 7.1899 0.3019 5.4500
117 7.1978 0.4928 4.1500
118 7.2554 0.1614 6.4100
119 7.3676 0.1772 5.9900
120 7.4885 -1.9053 5.5900
121 7.5350 1.9144 5.2500
122 7.7182 0.1894 6.1900
123 7.8617 1.7669 5.1400
124 7.9545 1.1269 6.3500
125 8.0204 -1.3925 4.6800
126 8.0971 0.5736 6.4100
127 8.3370 0.9094 6.1800
128 8.3556 -1.6022 6.5000
129 8.7875 -1.8972 5.2900
130 8.9689 1.5417 6.5900
131 9.0328 0.4828 5.6700
132 9.1166 1.4628 6.1700
133 9.4395 -1.4639 6.0100
134 9.4839 -1.2569 6.2700
135 9.5330 -1.1850 4.5700
136 9.5448 1.8642 6.1100
137 9.6643 -1.1428 3.9100
138 9.7732 1.7856 5.6500
139 9.8700 0.0756 6.3500
140 10.1323 0.3717 4.4900
141 10.5049 0.6369 5.0900
142 10.6901 -1.7417 6.2600
143 10.8113 -1.9589 5.9300
144 10.8705 1.0253 6.3800
145 10.8767 0.2014 6.3100
146 10.9284 0.7369 5.9100
147 11.0541 0.7525 6.1400
148 11.0602 0.0008 5.9500
149 11.1151 1.9556 5.5200
150 11.2293 0.0697 5.4200
151 11.2882 2.0106 5.1800
152 11.3153 1.6506 5.9100
153 11.3883 0.1317 6.0500
154 11.4006 1.4078 5.3900
155 11.4649 -1.7000 6.2500
156 11.6158 0.8239 4.3000
157 11.8170 0.3186 6.1500
158 11.8449 1.7647 3.6100
159 11.8973 0.5519 6.3000
160 11.9843 0.5306 6.1700
161 12.0172 -1.7681 6.3100
162 12.1615 1.8978 5.9500
163 12.3112 0.7872 5.9000
164 12.3318 0.6669 3.8900
165 12.6396 1.8547 5.7100
166 12.6943 -1.4494 3.6500
167 12.6943 -1.4494 3.6800
168 12.7272 -1.5769 5.9300
169 13.2738 -1.3906 6.6800
170 13.2916 0.6767 6.3700
171 13.4365 -1.1925 5.9700
172 13.4875 -1.3644 6.4300
173 13.5782 0.5958 3.3700
174 13.9117 -1.5031 5.1500
175 13.9411 1.0506 5.9100
176 14.0274 1.5444 4.2600
177 14.1920 1.3622 6.4300
178 14.2280 0.8456 5.9100
179 14.3280 0.3842 6.1900
180 14.3876 1.2417 6.2700
181 14.4974 0.8289 5.9400
182 14.7532 -1.4178 6.0700
183 14.7584 0.7172 5.6900
184 14.7708 1.8928 3.7200
185 14.8150 0.8478 6.1400
186 14.8500 0.2572 6.1800
187 14.9592 0.1675 5.5300
188 15.0303 0.1406 5.7100
189 15.2636 0.3722 5.6300
190 15.3073 0.4614 5.8900
191 15.3219 1.7653 5.0600
192 15.3506 0.7153 5.3500
193 15.3955 -1.0225 6.1200
194 15.4773 1.8422 5.1700
195 15.5494 -1.1864 5.5100
196 15.5846 1.6689 6.5600
197 15.6094 0.5617 6.5100
198 15.7610 0.8914 6.3300
199 15.7682 -1.8044 5.4000
200 16.3679 1.0292 4.8200
201 16.4761 0.6650 5.3900
202 16.5152 1.9839 3.8200
203 16.6865 -1.0006 6.2400
204 16.6951 1.1811 5.7400
205 16.7583 1.0203 6.0300
206 16.8569 1.2161 5.5100
207 16.9029 -1.6122 6.2500
208 17.0880 0.7025 6.0100
209 17.0923 0.8919 5.6400
210 17.1147 -1.6564 6.3800
211 17.1371 -1.0794 6.0600
212 17.2151 0.3519 6.6500
213 17.2755 1.2106 5.8800
214 17.2769 0.4453 4.7300
215 17.4328 -1.6517 6.4400
216 17.4805 0.3306 5.4400
217 17.5066 -1.0625 5.3100
218 17.6524 2.0281 6.2600
219 17.8219 1.9611 6.4700
220 17.8665 -1.2367 6.3500
221 17.8765 1.3050 5.9500
222 17.9384 0.6703 5.8200
223 17.9512 0.0664 5.9700
224 18.0043 0.6294 6.3700
225 18.0292 1.3053 4.4500
226 18.0770 1.9192 6.1400
227 18.1021 0.4467 6.3400
228 18.2847 1.0058 6.6300
229 18.4158 -1.5794 6.1500
230 18.4535 0.1961 5.2100
231 18.4947 -1.9853 5.3900
232 18.5325 -1.0031 5.9400
233 18.6267 0.3094 5.7500
234 18.6386 -1.1133 6.6600
235 18.7746 0.9617 5.9000
236 18.8270 0.8358 6.2500
237 18.9396 -1.8000 6.2200
238 19.0589 1.8189 5.8300
239 19.0885 -1.5128 6.5300
240 19.1192 0.6417 6.5600
241 19.1643 0.4281 6.3400
242 19.2967 2.0317 6.1900
243 19.3090 1.0853 5.1000
244 19.3141 0.3392 6.4100
245 19.3432 0.8922 5.4900
246 19.3726 0.2525 5.8300
247 19.4420 0.3386 4.6600
248 19.4836 1.9503 5.8000
249 19.4883 0.2461 6.2500
250 19.6120 -1.2864 4.3600
251 19.6787 0.6211 5.6700
252 19.8746 1.0056 3.9000
253 19.9124 0.2736 5.6100
254 19.9896 1.3778 6.1700
255 20.0731 0.7094 5.6800
256 20.1338 0.6783 5.9900
257 20.1884 0.8214 3.2300
258 20.2098 0.8675 6.2700
259 20.2205 -1.0094 5.4700
260 20.3287 -1.0786 6.0600
261 20.4104 1.0686 6.1500
262 20.6218 0.0969 6.2200
263 20.6390 -1.1053 4.3200
264 20.6569 0.4864 5.1600
265 20.9189 -1.3733 6.5500
266 20.9529 0.4636 6.0500
267 21.0499 0.9247 6.5000
268 21.0508 1.5319 6.2500
269 21.2436 0.0922 6.3800
270 21.2777 -1.6078 6.4800
271 21.4310 0.5344 6.4600
272 21.4411 1.1033 6.1300
273 21.6261 0.3903 6.2500
274 21.7028 1.2853 5.6700
275 22.0181 0.6050 5.5800
276 22.0798 0.9067 5.3000
277 22.0964 0.3197 2.9600
278 22.2760 -1.5964 6.1500
279 22.3012 0.2378 6.3900
280 22.3609 -1.3872 3.8400
281 22.4213 1.3775 4.6600
282 22.4805 0.0203 4.5900
283 22.4806 0.0200 4.4200
284 22.5675 -1.5742 5.8900
285 22.5893 0.1175 4.0200
286 22.9165 1.0647 6.1100
287 22.9732 -1.4103 6.3700
288 22.9909 0.9628 5.4300
289 23.0105 0.1858 6.2100
290 23.0882 1.3069 6.3900
291 23.3922 0.2914 6.3100
292 23.4489 1.2556 4.9400
293 23.4541 1.1225 6.2500
294 23.5327 -1.0858 6.3800
295 23.5692 -1.2475 5.8700
296 23.7008 1.7800 4.5000
297 23.8243 1.0761 5.7700
298 23.9129 0.1092 5.6100
Explanation / Answer
#include<iostream>
#include<stdlib.h>
using namespace std;
void fun_field(int raval, int decval);
void in_FOV(int raval);
void fun_pix_pd();
int main()
{
int chc, strno, len=5;
float ra[5], dec[5];
int raval, decval;
cout << "Please enter the star catalogs: ";
cout << "First enter the RA then DEC: (Ex: 1.0 2.0) ";
for(int i=0; i<5;i++)
{
cin >> ra[i];
cin >> dec[i];
}
cout << "STAR CATALOG ";
cout << "STAR NO RA DEC ";
for(strno=0; strno<5;strno++)
{
cout << strno <<" "<< ra[strno] <<" "<< dec[strno]<< " ";
}
lbl1:
cout << "Please enter the choice: " << " 1: View list of stars that are within some fixed field 2: camera direction is an input 3: print out the pixel location of where the each star should be 4: EXIT ";
cin>> chc;
if(chc!=1 || chc!=2 || chc!=3 || chc!=4 )
goto lbl1;
switch(chc)
{
case 1:
cout << "Please enter the choice: " << " Enter values of (RA,DEC) such as (10 0 ), ( +/- 2 degrees in DEC, +/- 3 degrees in RA) of some point in the sky. ";
cin>> raval; cin>> decval;
fun_field(raval, decval);
break;
case 2:
cout << "Please enter the choice: " << " Enter values of (RA) such as (10)";
cin>> raval;
in_FOV(raval);
break;
case 3:
fun_pix_pd();
break;
case 4:
exit(0);
}
void fun_field(int raval, int decval)
{
int r, d, flg=0;
r=raval; d=decval;
for(int rcnt=-(r+3) , dcnt=-(d+2), i=0; rcnt<(r+3) && dcnt<(d+2); rcnt++, dcnt++, i++ )
{
if(int(ra[i])== rcnt && int(dec[i])==dcnt)
{
cout << "Stars present :"<< i <<" "<< ra[i] <<" "<< dec[i]<< " "; flg++;
}
}
if(flg=0)
cout << "No Stars present in the given range";
}
void in_FOV(int raval)
{
int r, flg=0;
r=raval;
for(int j=0 , i=0; j<r; j++, i++ )
{
if(int(ra[i])== j && int(dec[i])==0)
{
cout << i <<" "<< ra[i] <<" "<< dec[i]<< " "; flg++;
}
}
if(flg=0)
cout << "No Stars present in the given range";
}
void fun_pix_pd()
{
float cnt;
for(int i=0; i<5; i++)
{
cnt=ra[i]*dec[i];
if(cnt > 24.0 )
{
pos=cnt-ra[i];
cout<< "The position relative to camera is" << int(pos);
cout << i <<" "<< ra[i] <<" "<< dec[i]<< " ";
}
}
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.