#define | SQRT2 1.41421356 |
#define | WALL_COST 1000 |
Cost fo jumping a wall. | |
GraphMapCell | graph [MAP_HEIGHT][MAP_WIDTH] |
void | pushNodeInOrder (NodeQueue *q, int x, int y) |
float | cFunction (int x1, int y1, int x2, int y2) |
#define | DBG printf |
#define | ABS_VAL(x) ((x > 0.0)?(x):(-x)) |
#define | POW(x) (x*x) |
#define | PATH_ERROR 0.09 |
PathPoint * | newPathPoint (PathPoint *last, float x, float y) |
void | calc_line (float x1, float y1, float x2, float y2, Line *l) |
float | calc_dist (Line *l, float x, float y) |
int | path_simplifier (double *path, int nbpoints, PathPoint *first_point, double *angle) |
#define PATH_ERROR 0.09 |
Max error for the path simplifier
Definition at line 20 of file path_simplifier.c.
Referenced by path_simplifier().
#define SQRT2 1.41421356 |
Root square of two.
Definition at line 17 of file aalgorithm.c.
Referenced by calculateCost(), and cFunction().
#define WALL_COST 1000 |
float calc_dist | ( | Line * | l, | |
float | x, | |||
float | y | |||
) |
Calc the distance between a line and a point
l | A pointer to line parameters | |
x | Coordonate X of the point | |
y | Coordonate Y of the point |
If it is a hotizontal line, the distance is the difference between y coordonate and b parameter.
If it is a vertical line, the distance is the difference between x coordonate and b parameter.
If it is a oblicuous line, the distance is .
Definition at line 77 of file path_simplifier.c.
References _Line::a1, _Line::a2, _Line::b, and POW.
Referenced by path_simplifier().
void calc_line | ( | float | x1, | |
float | y1, | |||
float | x2, | |||
float | y2, | |||
Line * | l | |||
) |
Calc line parameters from two points
x1 | Coordonate X of the first point | |
y1 | Coordonate Y of the first point | |
x2 | Coordonate X of the second point | |
y2 | Coordonate Y of the second point | |
l | A pointer to line parameters |
Returns parameters of a line : a1 * x + a2 * y = b
Definition at line 48 of file path_simplifier.c.
References _Line::a1, _Line::a2, and _Line::b.
Referenced by path_simplifier().
float cFunction | ( | int | x1, | |
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Calculates the lenght of edge connecting two points
x1 | Coordonate X of the first cell | |
y1 | Coordonate Y of the first cell | |
x2 | Coordonate X of the second cell | |
y2 | Coordonate Y of the second cell |
Definition at line 182 of file aalgorithm.c.
References ShmapIsFreeCell(), SQRT2, and WALL_COST.
Referenced by aAlgorithm().
Put the REAL coordonates (X,Y) in a list of points
last | Last point of the points list | |
x | Coordonate X of the first cell | |
y | Coordonate Y of the first cell |
Definition at line 30 of file path_simplifier.c.
Referenced by path_simplifier().
int path_simplifier | ( | double * | path, | |
int | nbpoints, | |||
PathPoint * | first_point, | |||
double * | angle | |||
) |
Simplify a given path
path | A pointer to a list of points of the original path | |
nbpoints | Number of points of the original path | |
first_point | [out] A pointer to the list of points of simplest path | |
angle | [out] Angle of the last line |
This is an algorithm who tries to simplify the path given by A* Algorithm (
first_index = 0; last_index = nbpoints; step = (last_index - first_index)/2 WHILE (the first index less than nbpoints ) Calc the line FOR all the points between path[first_index] and path[last_index] calc the distance betwen the point and the line Take the max_error END FOR IF max_error less than ACCEPTABLE_ERROR THEN The line is part of the simple path. first_index = last_index last_index = last_index + step ELSE reduce last_index step = (last_index - first_index)/2 last_index = last_index - step; END IF END WHILE
Definition at line 106 of file path_simplifier.c.
Referenced by path_planner().
void pushNodeInOrder | ( | NodeQueue * | q, | |
int | x, | |||
int | y | |||
) |
Push in the queue the cell (x,y) order by heuristic value of the cell
q | Coordonate X of the first cell | |
x | Coordonate X of a cell | |
y | Coordonate Y of a cell |
Definition at line 314 of file aalgorithm.c.
References _GraphMapCell::f, _NodeQueue::first, graph, _NodeQueue::last, _Node::next, queueIsEmpty(), _Node::x, and _Node::y.
Referenced by aAlgorithm().
GraphMapCell graph[MAP_HEIGHT][MAP_WIDTH] |
Graph structure used in A*.
Definition at line 20 of file aalgorithm.c.
Referenced by aAlgorithm(), calculateMapHeuristic(), getPathLength(), initGraphStructure(), and pushNodeInOrder().