39 Node(
int i = 0,
int j = 0,
Node *p =
nullptr,
double g = 0,
double h = 0)
40 : i(i), j(j), g(g), H(h), F(g+h), parent(p){}
74 Point(
float x,
float y);
85 virtual ~
Point() =
default;
103 std::pair<float, float> GetPair();
110 float ScalarProduct(
const Point &another)
const;
116 float EuclideanNorm()
const;
122 float SquaredEuclideanNorm()
const;
133 float Det(
Point another)
const;
139 std::string ToString()
const;
146 Point operator - (
const Point &another)
const;
153 Point operator + (
const Point &another)
const;
167 Point operator * (
float k)
const;
174 Point operator / (
float k)
const;
180 Point operator - ()
const;
187 virtual Point & operator = (
const Point &obj);
227 Vertex(
float x,
float y,
bool cvx =
false) :
Point(x, y), convex(cvx) {}
245 ~
Vertex()
override =
default;
251 bool IsConvex()
const;
257 void SetConvex(
bool cvx);
354 bool linearProgram1(
const std::vector<Line> &lines,
unsigned long curr,
float radius,
const Vector &optVelocity,
355 bool directionOpt,
Vector &result);
368 unsigned long int linearProgram2(
const std::vector<Line> &lines,
float radius,
const Vector &optVelocity,
369 bool directionOpt,
Vector &result);
381 void linearProgram3(
const std::vector<Line> &lines,
size_t numObstLines,
size_t beginLine,
382 float radius,
Vector &result);
392 bool More( std::pair<float, T> a, std::pair<float, T> b)
394 return (a.first > b.first);
404 bool Less( std::pair<float, T> a, std::pair<float, T> b)
406 return (a.first < b.first);
421 return i == another.
i &&
j == another.
j;
426 return i != other.
i ||
j != other.
j;
434 return (this->
id == another.
id);
451 return this->x * another.
x + this->y * another.
y;
457 return {this->x - another.
x, this->y - another.
y};
463 return {this->x + another.
x, this->y + another.
y};
469 return {this->x * k, this->y * k};
475 const float invK = 1.0f / k;
476 return {this->x * invK, this->y * invK};
482 return this->ScalarProduct(*
this);
488 return std::sqrt(this->ScalarProduct(*
this));
494 return (this->x * another.
y - this->y * another.
x);
500 return (this->x == another.
x) && (this->y == another.
y);
506 return Point(-this->x, -this->y);
ObstacleSegment & operator=(const ObstacleSegment &obj)
Assignment operator.
float SquaredEuclideanNorm() const
Computes squared euclidean norm of vector.
Node(int i=0, int j=0, Node *p=nullptr, double g=0, double h=0)
Node constructor with parameters.
Vector dir
Vector (right-left)/|right-left|.
bool linearProgram1(const std::vector< Line > &lines, unsigned long curr, float radius, const Vector &optVelocity, bool directionOpt, Vector &result)
Solves a one-dimensional linear program on a specified line subject to linear constraints defined by ...
Point operator/(float k) const
operator /
Vector dir
direction vector of line.
Point operator*(float k) const
operator *
The Node class defines a cell of grid (see Map class)
The class defines a line in 2D space.
Point operator-() const
operator -
ObstacleSegment * prev
Previous edge in obstacle.
Point operator+(const Point &another) const
operator +
bool More(std::pair< float, T > a, std::pair< float, T > b)
Comparison function for pairs of the form <float, T> For sorting purposes.
double g
g-value of node for A* based algorithms.
The ObstacleSegment class defines an edge of an obstacle polygon.
int id
Identifier of edge.
bool operator==(const Point &another) const
operator ==
The Point class defines a position (or euclidean vector from (0,0)) in 2D space.
Vertex()
Vertex default constructor.
Vertex & operator=(const Vertex &obj)
Assignment operator.
#define Vector
Vector type definition.
float x
X-coordinate of the point.
float EuclideanNorm() const
Computes euclidean norm of vector.
Vertex left
Left vertex of edge (when viewed from the outside of an obstacle).
Vertex(float x, float y, bool cvx=false)
Vertex constructor.
bool operator!=(const Node &other) const
operator !=
ObstacleSegment(int id, const Vertex &left, const Vertex &right)
ObstacleSegment constructor.
Vertex(const Vertex &obj)
Vertex copy constructor.
virtual Point & operator=(const Point &obj)
Assignment operator.
ObstacleSegment(const ObstacleSegment &obj)
Copy constructor.
double F
F = g + h. Value for A* based algorithms.
float Det(Point another) const
Computes the determinant of matrix.
int i
The number of row. Part of (i,j) address of cell on grid.
File contains main constants.
void linearProgram3(const std::vector< Line > &lines, size_t numObstLines, size_t beginLine, float radius, Vector &result)
Solves a two-dimensional linear program subject to linear constraints defined by lines and a circular...
float y
Y-coordinate of the point.
bool convex
Convexity of vertex.
float ScalarProduct(const Point &another) const
Computes scalar product of vectors (this * anoher)
ObstacleSegment * next
Next edge in obstacle.
unsigned long int linearProgram2(const std::vector< Line > &lines, float radius, const Vector &optVelocity, bool directionOpt, Vector &result)
Solves a two-dimensional linear program subject to linear constraints defined by lines and a circular...
Vertex right
Right vertex of edge (when viewed from the outside of an obstacle).
Vertex(const Point &obj, bool cvx=false)
Vertex constructor.
bool operator==(const ObstacleSegment &another) const
operator ==
int j
The number of column. Part of (i,j) address of cell on grid.
The set of utility functions.
float SqPointSegDistance(Point L1, Point L2, Point P)
Computes squared euclidean distance from point to line segment.
Node * parent
The node from which the transition to this node was made. Value for A* based algorithms.
Point liesOn
point on line.
The Vertex class defines a vertex of an obstacle polygon.
bool Less(std::pair< float, T > a, std::pair< float, T > b)
Comparison function for pairs of the form <float, T> For sorting purposes.
double H
h-value of node for A* based algorithms.
bool operator==(const Node &another) const
operator ==