-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnode.h
More file actions
executable file
·74 lines (58 loc) · 1.77 KB
/
node.h
File metadata and controls
executable file
·74 lines (58 loc) · 1.77 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
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef NODE_H
#define NODE_H
#include "gl_const.h"
#include <limits>
#include <list>
#include <iostream>
#include <cmath>
struct circleNode
{
int i, j;
double heading;
double cost;
circleNode(): i(-1), j(-1), heading(-1), cost(0) {}
circleNode(int i, int j, double cost): i(i), j(j), heading(-1), cost(cost) {}
circleNode(int i, int j, double heading, double cost): i(i), j(j), heading(heading), cost(cost) {}
};
struct Node {
Node* parent;
int i, j;
int radius;
float F;
float g;
double angle;
Node() : i(-1), j(-1), F(std::numeric_limits<float>::infinity()), g(std::numeric_limits<float>::infinity()),
parent(nullptr), radius(CN_PTD_D), angle(0) {}
Node(int x, int y, float g_=std::numeric_limits<float>::infinity(), double h_=std::numeric_limits<float>::infinity(),
float radius_=CN_PTD_D, Node *parent_=nullptr, float cweightdist_=0, double ang_=0) :
i(x), j(y), g(g_), radius(radius_), parent(parent_), angle(ang_) {
if (parent) {
F = g + h_ + cweightdist_ * fabs(ang_ - parent->angle);
} else {
F = g + h_;
}
}
~Node() {
parent = nullptr;
}
inline Node& operator=(const Node& other) {
i = other.i;
j = other.j;
F = other.F;
g = other.g;
parent = other.parent;
angle = other.angle;
radius = other.radius;
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);
}
int convolution(int width) const {
return i * width + j;
}
};
#endif