-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode.h
More file actions
62 lines (47 loc) · 1.58 KB
/
node.h
File metadata and controls
62 lines (47 loc) · 1.58 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef NODE_H
#define NODE_H
#include "gl_const.h"
#include <limits>
#include <list>
#include <iostream>
struct Node {
Node* parent;
bool pathToParent;
int i, j;
int radius;
float F;
float g;
float c; // curvature euristic component
Node() : i(-1), j(-1), F(std::numeric_limits<float>::infinity()), g(std::numeric_limits<float>::infinity()),
c(-1), parent(nullptr), pathToParent(false), radius(CN_PTD_D) {}
Node(int x, int y, float F_=std::numeric_limits<float>::infinity(), float g_=std::numeric_limits<float>::infinity(), float c_=-1) : i(x), j(y), F(F_), g(g_),
c(c_), parent(nullptr), pathToParent(false), radius(CN_PTD_D) {}
~Node() {
parent = nullptr;
}
inline Node& operator=(const Node& other) {
i = other.i;
j = other.j;
F = other.F;
g = other.g;
parent = other.parent;
pathToParent = other.pathToParent;
radius = other.radius;
c = other.c;
return *this;
}
inline bool operator==(const Node& p) const {
return i == p.i && j == p.j && parent->i == p.parent->i && parent->j == p.parent->j;
}
inline bool operator!=(const Node& p) const {
return !(*this == p);
}
bool lesser(const Node another, int BT) const {
return F < another.F || (F == another.F && ((BT == CN_BT_GMAX && g > another.g) ||
(BT == CN_BT_GMIN && g < another.g)));
}
int convolution(int width) const {
return i * width + j;
}
};
#endif