-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastar.cpp
More file actions
28 lines (26 loc) · 839 Bytes
/
Copy pathastar.cpp
File metadata and controls
28 lines (26 loc) · 839 Bytes
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
#include "astar.h"
Astar::Astar(double HW, bool BT)
{
hweight = HW;
breakingties = BT;
}
double Astar::computeHFromCellToCell(int i1, int j1, int i2, int j2, const EnvironmentOptions &options)
{
//need to implement
//#define CN_SP_MT_DIAG 0
//#define CN_SP_MT_MANH 1
//#define CN_SP_MT_EUCL 2
//#define CN_SP_MT_CHEB 3
int dx = abs(i1 - i2);
int dy = abs(j1 - j2);
if (options.metrictype == CN_SP_MT_DIAG) {
return (dx + dy) + (CN_SQRT_TWO - 2) * std::min(dx, dy);
} else if (options.metrictype == CN_SP_MT_MANH) {
return dx + dy;
} else if (options.metrictype == CN_SP_MT_EUCL) {
return std::hypot(dx, dy);
} else if (options.metrictype == CN_SP_MT_CHEB) {
return (dx + dy) - std::min(dx, dy);
}
return 0;
}