]> git.mxchange.org Git - simgear.git/blob - simgear/magvar/testmagvar.cxx
Add project.* to MSVC project files
[simgear.git] / simgear / magvar / testmagvar.cxx
1 /* 2/14/00 fixed help message- dip angle (down positive), variation (E positive) */
2
3 #include        <stdio.h>
4 #include        <stdlib.h>
5 #include        <math.h>
6
7 #include <simgear/constants.h>
8
9 #include "coremag.hxx"
10
11
12 int main(int argc, char *argv[])
13 {
14   /* args are double lat_deg, double lon_deg, double h, 
15                    int mm, int dd, int yy,int model */
16   /* output N, E, down components of B (nTesla)
17      dip angle (down positive), variation (E positive) */
18 double lat_deg,lon_deg,h,var;
19 int model,yy,mm,dd;
20 double field[6];
21
22 if ((argc != 8) && (argc !=7)) {
23 fprintf(stdout,"Usage: mag lat_deg lon_deg h mm dd yy [model]\n");
24 fprintf(stdout,"N latitudes, E longitudes positive degrees, h in km, mm dd yy is date\n");
25 fprintf(stdout,"model 1,2,3,4,5,6,7 <=> IGRF90,WMM85,WMM90,WMM95,IGRF95,WMM2000,IGRF2000\n");
26 fprintf(stdout,"Default model is IGRF2000, valid 1/1/00 - 12/31/05\n");
27 fprintf(stdout,"Output Bx (N) By (E) Bz (down) (in nTesla) dip (degrees down positive)\n");
28 fprintf(stdout,"variation (degrees E positive)\n");
29 exit(1);
30 }
31
32 lat_deg=strtod(argv[1],NULL);
33 lon_deg=strtod(argv[2],NULL);
34 h=      strtod(argv[3],NULL);
35 mm=     (int)strtol(argv[4],NULL,10);
36 dd=     (int)strtol(argv[5],NULL,10);
37 yy=     (int)strtol(argv[6],NULL,10);
38 if (argc == 8){
39   model=  (int)strtol(argv[7],NULL,10);
40 }else{
41   model=7;
42 }
43
44
45 var = calc_magvar( SGD_DEGREES_TO_RADIANS * lat_deg, SGD_DEGREES_TO_RADIANS * lon_deg, h,
46                    yymmdd_to_julian_days(yy,mm,dd), field );
47
48 fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[0], field[1], field[2] );
49 fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[3], field[4], field[5] );
50 fprintf(stdout,"%6.0f %6.0f %6.0f %4.2f %4.2f \n",
51   field[3],field[4],field[5],
52   SGD_RADIANS_TO_DEGREES * (atan(field[5]/pow(field[3]*field[3]+field[4]*field[4],0.5))),
53   SGD_RADIANS_TO_DEGREES * var);
54 exit(0);
55 }
56   
57   
58