17 if ((Na->
Id <= n) == (Nb->
Id <= n))
19 if (abs(Na->
Id - Nb->
Id) == n)
21 return Na->
Id < Nb->
Id ? Na->
C[Nb->
Id - n] : Nb->
C[Na->
Id - n];
26 double xd = Na->
X - Nb->
X, yd = Na->
Y - Nb->
Y;
27 return (
int) ceil(sqrt((xd * xd + yd * yd) / 10.0));
32 double xd = Na->
X - Nb->
X, yd = Na->
Y - Nb->
Y;
33 return (
int) ceil(sqrt(xd * xd + yd * yd));
38 double xd = Na->
X - Nb->
X, yd = Na->
Y - Nb->
Y, zd = Na->
Z - Nb->
Z;
39 return (
int) ceil(sqrt(xd * xd + yd * yd + zd * zd));
44 double xd = Na->
X - Nb->
X, yd = Na->
Y - Nb->
Y;
45 return (
int) (sqrt(xd * xd + yd * yd) + 0.5);
50 double xd = Na->
X - Nb->
X, yd = Na->
Y - Nb->
Y, zd = Na->
Z - Nb->
Z;
51 return (
int) (sqrt(xd * xd + yd * yd + zd * zd) + 0.5);
56 return Na->
Id < Nb->
Id ? Nb->
C[Na->
Id] : Na->
C[Nb->
Id];
65 double NaLatitude, NaLongitude, NbLatitude, NbLongitude, min, q1, q2,
69 NaLatitude =
PI * (deg + 5.0 * min / 3.0) / 180.0;
72 NaLongitude =
PI * (deg + 5.0 * min / 3.0) / 180.0;
75 NbLatitude =
PI * (deg + 5.0 * min / 3.0) / 180.0;
78 NbLongitude =
PI * (deg + 5.0 * min / 3.0) / 180.0;
79 q1 = cos(NaLongitude - NbLongitude);
80 q2 = cos(NaLatitude - NbLatitude);
81 q3 = cos(NaLatitude + NbLatitude);
82 return (
int) (
RRR * acos(0.5 * ((1.0 + q1) * q2 - (1.0 - q1) * q3)) +
87 #define M_PI 3.14159265358979323846264 88 #define M_RRR 6378388.0 92 double lati =
M_PI * (Na->
X / 180.0);
93 double latj =
M_PI * (Nb->
X / 180.0);
94 double longi =
M_PI * (Na->
Y / 180.0);
95 double longj =
M_PI * (Nb->
Y / 180.0);
96 double q1 = cos(latj) * sin(longi - longj);
97 double q3 = sin((longi - longj) / 2.0);
98 double q4 = cos((longi - longj) / 2.0);
99 double q2 = sin(lati + latj) * q3 * q3 - sin(lati - latj) * q4 * q4;
100 double q5 = cos(lati - latj) * q4 * q4 - cos(lati + latj) * q3 * q3;
101 return (
int) (
M_RRR * atan2(sqrt(q1 * q1 + q2 * q2), q5) + 1.0);
106 return (
int) (fabs(Na->
X - Nb->
X) + fabs(Na->
Y - Nb->
Y) + 0.5);
111 return (
int) (fabs(Na->
X - Nb->
X) +
112 fabs(Na->
Y - Nb->
Y) + fabs(Na->
Z - Nb->
Z) + 0.5);
117 int dx = (int) (fabs(Na->
X - Nb->
X) + 0.5),
118 dy = (int) (fabs(Na->
Y - Nb->
Y) + 0.5);
119 return dx > dy ? dx : dy;
124 int dx = (int) (fabs(Na->
X - Nb->
X) + 0.5),
125 dy = (int) (fabs(Na->
Y - Nb->
Y) + 0.5),
126 dz = (int) (fabs(Na->
Z - Nb->
Z) + 0.5);
129 return dx > dz ? dx : dz;
139 static double Meeus(
double lat1,
double lon1,
double lat2,
double lon2)
141 const double a = 6378.137;
142 const double fl = 1 / 298.257;
143 double f, g, l, sg, sl, sf,
s,
c, w,
r,
d, h1, h2;
145 if (lat1 == lat2 && lon1 == lon2)
147 f = (lat1 + lat2) / 2;
148 g = (lat1 - lat2) / 2;
149 l = (lon1 - lon2) / 2;
156 s = sg * (1 - sl) + (1 - sf) * sl;
157 c = (1 - sg) * (1 - sl) + sf * sl;
158 w = atan(sqrt(s / c));
161 h1 = (3 * r - 1) / 2 / c;
162 h2 = (3 * r + 1) / 2 / s;
164 (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg)));
170 M_PI * ((int) Na->
X + 5 * (Na->
X - (
int) Na->
X) / 3) / 180;
172 M_PI * ((int) Na->
Y + 5 * (Na->
Y - (
int) Na->
Y) / 3) / 180;
174 M_PI * ((int) Nb->
X + 5 * (Nb->
X - (
int) Nb->
X) / 3) / 180;
176 M_PI * ((int) Nb->
Y + 5 * (Nb->
Y - (
int) Nb->
Y) / 3) / 180;
177 return (
int) (
Meeus(lat1, lon1, lat2, lon2) + 0.5);
182 double lat1 =
M_PI * (Na->
X / 180);
183 double lon1 =
M_PI * (Na->
Y / 180);
184 double lat2 =
M_PI * (Nb->
X / 180);
185 double lon2 =
M_PI * (Nb->
Y / 180);
186 return (
int) (1000 *
Meeus(lat1, lon1, lat2, lon2) + 0.5);
int Distance_EXPLICIT(Node *Na, Node *Nb)
static double Meeus(double lat1, double lon1, double lat2, double lon2)
int Distance_MAN_2D(Node *Na, Node *Nb)
int Distance_GEOM(Node *Na, Node *Nb)
int Distance_MAX_2D(Node *Na, Node *Nb)
int Distance_1(Node *Na, Node *Nb)
int Distance_GEO_MEEUS(Node *Na, Node *Nb)
int Distance_MAN_3D(Node *Na, Node *Nb)
int Distance_ATSP(Node *Na, Node *Nb)
int Distance_MAX_3D(Node *Na, Node *Nb)
int Distance_GEO(Node *Na, Node *Nb)
int Distance_EUC_3D(Node *Na, Node *Nb)
int Distance_EUC_2D(Node *Na, Node *Nb)
int Distance_GEOM_MEEUS(Node *Na, Node *Nb)
int Distance_CEIL_3D(Node *Na, Node *Nb)
int Distance_CEIL_2D(Node *Na, Node *Nb)
int Distance_ATT(Node *Na, Node *Nb)