Path 1.0
ShortestPathGraph Class Reference

Shortest path algorithms over a height field. More...

#include <shortestgraph.h>

Inheritance diagram for ShortestPathGraph:
Array2 Box2

Public Member Functions

 ShortestPathGraph (const HeightField &, int=1, const HeightCost &=HeightCost(1.0, 1.0, 0.125, 1.0))
 Create the shortest path graph.
 
const CostGraphGraph () const
 Return a const reference to the graph.
 
QVector< QPoint > ShortestPath (const Vector2 &, const Vector2 &) const
 Compute the shortest path.
 
QVector< QPoint > ShortestPath (const QPoint &, const QPoint &) const
 Compute the shortest path.
 
QVector< VectorShortestPathVertexes (const Vector2 &, const Vector2 &) const
 Compute the shortest path.
 
virtual double Cost (const Vector2 &, const Vector2 &) const
 Compute the cost along a line segment.
 

Static Public Attributes

static const double Infinity = 1.0e8
 Maximum cost.
 

Protected Attributes

const HeightField & terrain
 Reference to heightfield.
 
CostGraph cg
 Graph used for shortest path computation.
 
int mask = 0
 Size of the mask.
 
double celldiagonallength
 Diagonal of a cell, precomputed from the argument terrain to speed-up computations.
 
HeightCost function
 Cost function.
 

Detailed Description

Shortest path algorithms over a height field.

Constructor & Destructor Documentation

◆ ShortestPathGraph()

ShortestPathGraph::ShortestPathGraph ( const HeightField & t,
int n = 1,
const HeightCost & f = HeightCost(1.0, 1.0, 0.125, 1.0) )

Create the shortest path graph.

Mask size is defined as:

Mask Neighborhood Connexity
0,1 1 4 ,8
2-7 2-7 16, 32, 48, ...
See also
MaskNext::size
Parameters
tTerrain.
nSize of the neighborhood mask.
fCost function.

Member Function Documentation

◆ Cost()

double ShortestPathGraph::Cost ( const Vector2 & a,
const Vector2 & b ) const
virtual

Compute the cost along a line segment.

Evaluate the integral of the function of the slope over a given segment.

Parameters
a,bSegment.

◆ ShortestPath() [1/2]

QVector< QPoint > ShortestPathGraph::ShortestPath ( const QPoint & s,
const QPoint & e ) const

Compute the shortest path.

Parameters
s,eStarting and end (target) point.
Returns
Set of points defining the path.

◆ ShortestPath() [2/2]

QVector< QPoint > ShortestPathGraph::ShortestPath ( const Vector2 & s,
const Vector2 & e ) const

Compute the shortest path.

Parameters
s,eStarting and end (target) vertexes.
Returns
Set of points defining the path.

◆ ShortestPathVertexes()

QVector< Vector > ShortestPathGraph::ShortestPathVertexes ( const Vector2 & s,
const Vector2 & e ) const

Compute the shortest path.

Parameters
s,eStarting and end (target) vertexes.
Returns
Set of vertexes targeted onto the terrain.

This is a convenience function equivalent to:

HeightField h;
QVector<QPoint> q = graph.ShortestPath(a, b); // Set of points
QVector<Vector> = h.ArrayVertexes(q); // Vertexes
Vector2 b
ShortestPathGraph(const HeightField &, int=1, const HeightCost &=HeightCost(1.0, 1.0, 0.125, 1.0))
Create the shortest path graph.
Definition shortest-path-graph.cpp:29

The documentation for this class was generated from the following files: