blob: ec22262d01d4e10f5ffb880cb9e78a61d87ae0e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Great Circle Distance mit Längen- und Breitengrad.
double gcDist(double pLat, double pLon,
double qLat, double qLon, double radius) {
pLat *= PI / 180; pLon *= PI / 180;
qLat *= PI / 180; qLon *= PI / 180;
return radius * acos(cos(pLat) * cos(pLon) *
cos(qLat) * cos(qLon) +
cos(pLat) * sin(pLon) *
cos(qLat) * sin(qLon) +
sin(pLat) * sin(qLat));
}
// Great Circle Distance mit kartesischen Koordinaten.
double gcDist(point p, point q) {
return acos(p.x * q.x + p.y * q.y + p.z * q.z);
}
// 3D Punkt in kartesischen Koordinaten.
struct point{
double x, y, z;
point() {}
point(double x, double y, double z) : x(x), y(y), z(z) {}
point(double lat, double lon) {
lat *= PI / 180.0; lon *= PI / 180.0;
x = cos(lat) * sin(lon);
y = cos(lat) * cos(lon);
z = sin(lat);
}
};
|