__Program w jezyku c na obliczanie poprawek na wspolrzedne rownikowe II ze wzgledu na:%BR%__ __- abberacje dobowa%BR%__ __- paralakse%BR%__ __- refrakcje atmosferyczna%BR%__ _Program sklada sie z 2 czesci: Poprawki.cc, czyli program glowny oraz convert.h, ktory sluzy do zamiany danych podawanych_ _jako: stopnie, minuty, sekundy lub godzinny, minuty, sekundy na liczbe.%BR%_ ---- *Poprawki.cc* <verbatim> // Program: Popraw // Autor: Bogna Pazderska // "Poprawki na abberacje, paralakse, refrakcje" #include <iostream.h> #include <math.h> #include <stdlib.h> #include <stdio.h> #include "convert.h" char tmp[30]; main () { int n, q; const double a = 6378.140; // w km const double f = 1 / (298.257); const double w = 0.000073; //w rad/s const double c = 299793; //w km/s const double P = 3.141592654; float s; double d, r, g, t, R, D, x, y, z; char dek[20]; char rek[20]; q = 0; while (q == 0) { cout << endl << "\tWybierz operacje ktora chcesz wykonac:" << endl; cout << "1 - Poprawka wspolrzednych rownikowych ze wzgledu na abberacje dobowa" << endl; cout << "2 - Poprawka wspolrzednych rownikowych ze wzgledu na paralakse" << endl; cout << "3 - Poprawka wspolrzednych rownikowych ze wzgledu na refrakcje" << endl; cout << "4 - Zakonczenie programu" << endl; cin >> n; switch (n) { case 1: case 2: case 3: cout << "\tStare wspolrzedne: - deklinacja(_d_m...s): " << flush; cin >> tmp; d = convert (tmp); //cout<<d<<endl; if ((d == 90) || (d == -90)) { cout << "Przypadek niemozliwy do wyliczenia" << endl; exit (1); } else if ((d > 90) || (d < -90)) { cout << "Deklinacja musi byc miedzy -90d, a 90d (degree)" << endl; exit (2); } d = (d / 360) * 2 * P; cout << "\t - rektascencja(_h_m...s): " << flush; cin >> tmp; r = convert (tmp); if ((r < 0) || (r > 360)) { cout << "Rektascencja musi byc miedzy 0h, a 24h " << endl; exit (4); } //cout<<r<<endl; r = (r / 360) * 2 * P; cout << "\tCzas gwiazdowy(_h_m...s): " << flush; cin >> tmp; t = convert (tmp); if ((t < 0) || (t > 360)) { cout << "Czas gwiazdowy musi byc miedzy 0h, a 24h" << endl; exit (3); } t = (t / 360) * 2 * P; t = t - r; cout << "\tSzerokosc geograficzna(_d_m...s): " << flush; cin >> tmp; s = convert (tmp); if (s > 90) { cout << "Szerokosc geograficzna musi byc miedzy 0d, a 90d (degree)" << endl; exit (4); } if (s == 90) { g = a * (1 - f); s = (s / 360) * 2 * P; } else { s = (s / 360) * 2 * P; g = (1 + pow (tan (s), 2)) / (1 + (pow (tan (s), 2) / pow ((1 - f), 2))); g = a * sqrt (g); } if (n == 1) { R = g * w * cos (s) * cos (t) / (cos (d) * c); D = g * w * cos (s) * sin (t) * sin (d) / c; } else if (n == 2) { double j; cout << "\nOdleglosc do obiektu(w km):" << flush; cin >> j; if (j <= 0) { cout << "\nOdleglosc musi byc dodatnia!" << endl; exit (5); } R = -(g * cos (s) * sin (t) / (cos (d) * j)); D = g * (cos (s) * cos (t) * sin (d) - sin (s) * cos (d)) / j; } else { double K; cout << "\nStala \"K\" refrakcji(_d_m...s): " << flush; cin >> tmp; K = convert (tmp); K = (K / 360) * 2 * P; if ((s == P / 2) && (d == 0.0)) { R = K * sin (t) / (pow (cos (d), 2) * (cos (t))); D = K * (tan (s) - tan (d) * cos (t)) / cos (t); } else if (s == P / 2) R = D = 0; else if (cos (t) + tan (s) * tan (d) == 0) exit (5); else { R = K * sin (t) / (pow (cos (d), 2) * (cos (t) + tan (s) * tan (d))); D = K * (tan (s) - tan (d) * cos (t)) / (cos (t) + tan (s) * tan (d)); } } if (n == 1) cout << " \n\tABBERACJA DOBOWA" << endl; if (n == 2) cout << " \n\tPARALAKSA" << endl; if (n == 3) cout << " \n\tREFRAKCJA ATMOSFERYCZNA" << endl; //Deklinacja x = (60.0 * (180.0 * fabs (D) / P - (int) (180.0 * fabs (D) / P))); y = ((x - (int) x) * 60); if ((D < 0) && ((int) (180.0 * D / P) == 0)) sprintf (dek, "-%1dd%02im%.6fs", (int) (180.0 * D / P), (int) x, y); else sprintf (dek, "%4dd%02im%.6fs", (int) (180.0 * D / P), (int) x, y); cout << " Poprawka na deklinacje: " << dek << flush; d = d + D; x = (60.0 * (180.0 * fabs (d) / P - (int) (180.0 * fabs (d) / P))); y = ((x - (int) x) * 60); if ((d < 0) && ((int) (180.0 * d / P) == 0)) sprintf (dek, "-%1id%02im%.6fs", (int) (180.0 * d / P), (int) x, y); else sprintf (dek, "%4id%02im%.6fs", (int) (180.0 * d / P), (int) x, y); cout << " Nowa deklinacja: " << dek << endl; //Rektascencja x = (60.0 * (12.0 * fabs (R) / P - (int) (12.0 * fabs (R) / P))); y = ((x - (int) x) * 60); if ((R < 0) && ((int) (12.0 * R / P) == 0)) sprintf (rek, "-%1ih%02im%.6fs ", (int) (12.0 * R / P), (int) x, y); else sprintf (rek, "%4ih%02im%.6fs ", (int) (12.0 * R / P), (int) x, y); cout << "Poprawka na rektascencje:" << rek << flush; r = r + R; x = (60.0 * (12.0 * fabs (r) / P - (int) (12.0 * fabs (r) / P))); y = ((x - (int) x) * 60); if ((r < 0) && ((int) (12.0 * r / P) == 0)) sprintf (rek, "-%1ih%02im%.6fs", (int) (12.0 * r / P), (int) x, y); else sprintf (rek, "%4ih%02im%.6fs", (int) (12.0 * r / P), (int) x, y); cout << " Nowa rektascencja: " << rek << endl; cout << "\nCzy chcesz kontynuowac(y/n): " << flush; cin >> tmp[1]; tmp[1]=(char)tmp[1]; if (tmp[1] == 'n') q = 1; break; default: cout << "\n\tDo nastepnego razu\n" << endl; exit (0); break; } } return 0; } </verbatim> --- *convert.h* <verbatim> #include <string.h> #include <ctype.h> double convert (char *s) { char c; char lili[20]; int i = 0, k; int j = strlen (s); for (k=0;k<j;k++) { c=toupper(s[k]); s[k]=c; } char typ = 'N'; double x; int sign = 1; while (i < j) { if ((s[i] == 'H') || (s[i] == ':')) { typ = 'H'; break; } else if (s[i] == 'D') { typ = 'D'; break; } i++; } i = 0; while (i < j) { if (isdigit (s[i])) break; else if (s[i] == '-') { sign = -1; i++; break; } else i++; } switch (typ) { case 'N': x = atof (s); break; case 'H': case 'D': k = 0; while (((s[i] == '.') || isdigit (s[i])) && (i < j)) lili[k++] = s[i++]; lili[k] = 0; x = atof (lili); k = 0; i++; while (((s[i] == '.') || isdigit (s[i])) && (i < j)) lili[k++] = s[i++]; lili[k] = 0; x += atof (lili) / 60.0; k = 0; i++; while (((s[i] == '.') || isdigit (s[i])) && (i < j)) lili[k++] = s[i++]; lili[k] = 0; x += atof (lili) / 3600.0; x *= sign; break; } if (typ == 'H') x *= 15.0; return x; } </verbatim> -- Main.BognA - 28 Apr 2004
This topic: Main
>
TWikiUsers
>
BognA
>
PrograM2
Topic revision:
28 Apr 2004,
BognA
(raw view)
Copyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki?
Send feedback