AIRS Code Collection
distance.c
Go to the documentation of this file.
1/*
2 This file is part of the AIRS Code Collection.
3
4 the AIRS Code Collections is free software: you can redistribute it
5 and/or modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation, either version 3 of
7 the License, or (at your option) any later version.
8
9 The AIRS Code Collection is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with the AIRS Code Collection. If not, see
16 <http://www.gnu.org/licenses/>.
17
18 Copyright (C) 2019-2025 Forschungszentrum Juelich GmbH
19*/
20
26#include "jurassic.h"
27
28int main(
29 int argc,
30 char *argv[]) {
31
32 double x0[3], x1[3];
33
34 /* Check arguments... */
35 if (argc < 5)
36 ERRMSG("Give parameters: <lon0> <lat0> <lon1> <lat1>");
37
38 /* Read geolocations... */
39 const double lon0 = atof(argv[1]);
40 const double lat0 = atof(argv[2]);
41 const double lon1 = atof(argv[3]);
42 const double lat1 = atof(argv[4]);
43
44 /* Write distance to stdout... */
45 geo2cart(0, lon0, lat0, x0);
46 geo2cart(0, lon1, lat1, x1);
47 printf("%g\n", DIST(x0, x1));
48
49 return EXIT_SUCCESS;
50}
int main(int argc, char *argv[])
Definition: distance.c:28
void geo2cart(const double z, const double lon, const double lat, double *x)
Convert geolocation to Cartesian coordinates.
Definition: jurassic.c:3500
JURASSIC library declarations.
#define ERRMSG(...)
Print error message and quit program.
Definition: jurassic.h:237
#define DIST(a, b)
Compute Cartesian distance between two vectors.
Definition: jurassic.h:134