|
Search Grid
AUVSI Search Path Algorithm 2019-2021
|
Polygon decomposition and traversal algorithm structs and functions. Implements the greedy recursive approach using minimum width sum outlined in a paper by Yan Li et al. All units are in meters. More...
#include <iostream>#include <algorithm>#include <cmath>#include <vector>#include <list>#include <string>#include <sstream>#include <fstream>#include <assert.h>#include <cfloat>#include <utility>#include "Graph.cpp"#include "Config.h"Classes | |
| struct | Coord |
| Simple representation of a 2D coordinate. More... | |
| struct | Edge |
| Simple representation of an edge. More... | |
| struct | Span |
| Representation of a span in Vertex-Edge form. More... | |
| struct | Polygon |
| Represents a polygon as a list of vertices in CCW order. More... | |
| struct | Node |
| Node class for weighted graph. Consists of the search path for the polygon, a pointer to the polygon, and the start state. More... | |
| struct | Comp |
Macros | |
| #define | PI 3.14159265358979323846 |
| Approximate value for pi. | |
| #define | INF 1000000 |
| An effective infinity that will not overflow the float type. More... | |
Enumerations | |
| enum | State { START_V1, START_V2, END_V1, END_V2 } |
| State representing which vertex we start the path from. START_V1 = start at vertex 1 of starting edge START_V2 = start at vertex 2 of starting edge END_V1 = start at vertex 1 of end edge END_V2 = start at vertex 2 of end edge. | |
Functions | |
| float_type | distance (const Coord &v1, const Coord &v2) |
| Find the distance between two vertices. More... | |
| float_type | distance (const Coord &v, const Edge &e) |
| Find the distance between a vertex and an edge. More... | |
| Span | getWidth (const Polygon &p) |
| Find the width of a convex polygon. More... | |
| bool | isConcave (const Polygon &p, int i) |
| Determine if a given vertex of a polygon is concave. More... | |
| void | split (const Polygon &p, int v1, int v2, Polygon &p1, Polygon &p2) |
| Splits a polygon into two along an edge. More... | |
| void | decompose (const Polygon &p, std::list< Polygon > &l) |
| Decompose a concave polygon into multiple convex polygons. More... | |
| Polygon | merge (const Polygon &p1, const Polygon &p2, unsigned int i, unsigned int j) |
| Merge two polygons by their shared edge given the edge's index in each polygon and return the result. More... | |
| void | mergeSubregions (std::list< Polygon > &l) |
| Combine applicable subregions after decomposition. More... | |
| float_type | cross (const Coord &c1, const Coord &c2) |
| Calculate the cross product of two vectors represented as coordinates. More... | |
| bool | intersection (const Edge &e1, const Edge &e2, Coord &intersect) |
| Find the intersection of two line segments. More... | |
| void | traverse (const Polygon &p, std::list< Edge > &waypoints) |
| Traverse a convex polygon and store the waypoints in a list as Edges. More... | |
| void | computeGraph (Graph< Node, float_type > &g) |
| Helper function to compute the adjacencies and weights of the graph. More... | |
| float_type | traversalLength (const Graph< Node, float_type > &g, std::list< unsigned int > &path) |
| Compute the total length of a graph traversal. More... | |
| std::list< unsigned int > | minTraversal (Graph< Node, float_type > &g) |
| Compute the minimum cost traversal for the weighted graph. More... | |
| void | computeStates (std::list< unsigned int > &path, Graph< Node, float_type > &g) |
| Determine the start states of each node along the traversal. More... | |
| std::list< Coord > | searchPath (const Polygon &p) |
| Generates the search path for a polygon. More... | |
| bool | clockwise (const std::vector< Coord > &v) |
| Determine if the list of coordinates are in clockwise order. More... | |
| std::list< Coord > | pathTo (const Coord &point1, const Coord &point2, const Polygon &boundary) |
| Computes a path from one point to another that does not intersect the boundary polygon. Assumes both points are inside the boundary polygon. More... | |
| void | naiveTraverse (const Polygon &p, std::list< Edge > &waypoints) |
| Traverse the polygon using a simple parallel traversal. More... | |
| std::list< Coord > | naivePath (const Polygon &p) |
| Generates a search path for a polygon using naive traversal. More... | |
| void | pathToHelp (std::list< Coord > &path, std::list< Coord >::iterator point1, std::list< Coord >::iterator point2, const Polygon &boundary) |
Polygon decomposition and traversal algorithm structs and functions. Implements the greedy recursive approach using minimum width sum outlined in a paper by Yan Li et al. All units are in meters.
| #define INF 1000000 |
An effective infinity that will not overflow the float type.
| bool clockwise | ( | const std::vector< Coord > & | v | ) |
Determine if the list of coordinates are in clockwise order.
| v | the list of coordinates |
| void computeGraph | ( | Graph< Node, float_type > & | g | ) |
Helper function to compute the adjacencies and weights of the graph.
| g | the graph to compute |
| void computeStates | ( | std::list< unsigned int > & | path, |
| Graph< Node, float_type > & | g | ||
| ) |
Determine the start states of each node along the traversal.
| path | the traversal |
| g | the weighted graph |
|
inline |
Calculate the cross product of two vectors represented as coordinates.
| c1 | the first vector as a coordinate |
| c2 | the second vector as a coordinate |
Decompose a concave polygon into multiple convex polygons.
| p | the polygon |
| l | stores the resulting list of polygons |
| float_type distance | ( | const Coord & | v, |
| const Edge & | e | ||
| ) |
Find the distance between a vertex and an edge.
| v | the vertex |
| e | the edge |
| float_type distance | ( | const Coord & | v1, |
| const Coord & | v2 | ||
| ) |
Find the distance between two vertices.
| v1 | the first vertex |
| v2 | the second vertex |
| bool isConcave | ( | const Polygon & | p, |
| int | i | ||
| ) |
Determine if a given vertex of a polygon is concave.
| p | the polygon |
| i | index of the vertex |
Merge two polygons by their shared edge given the edge's index in each polygon and return the result.
| p1 | the first polygon |
| p2 | the second polygon |
| i | index of the shared edge in p1 |
| j | index of the shared edge in p2 |
| void mergeSubregions | ( | std::list< Polygon > & | l | ) |
| std::list< unsigned int > minTraversal | ( | Graph< Node, float_type > & | g | ) |
Compute the minimum cost traversal for the weighted graph.
| g | the weighted graph |
Generates a search path for a polygon using naive traversal.
| p | the polygon |
Generates the search path for a polygon.
| p | the polygon |
Splits a polygon into two along an edge.
| p | the polygon |
| v1 | first vertex of edge |
| v2 | second vertex of edge |
| p1 | stores the first resulting polygon |
| p2 | stores the second resulting polygon |
| float_type traversalLength | ( | const Graph< Node, float_type > & | g, |
| std::list< unsigned int > & | path | ||
| ) |
Compute the total length of a graph traversal.
| g | the weighted graph |
| path | the traversal path |