DHART
Loading...
Searching...
No Matches
HF::SpatialStructures Namespace Reference

Contains standard fundamental data structures for representing space used throughout DHARTAPI. More...

Namespaces

namespace  CostAlgorithms
 

Classes

struct  CSRPtrs
 A struct to hold all necessary information for a CSR. More...
 
struct  Edge
 A connection to a child node. More...
 
class  EdgeCostSet
 A set of edge costs for a graph. More...
 
struct  EdgeSet
 A collection of edges and a parent. More...
 
class  Graph
 A Graph of nodes connected by edges that supports both integers and HF::SpatialStructures::Node. More...
 
struct  IntEdge
 A lighter version of Edge that contains an ID instead of a full node object.. More...
 
struct  Node
 A point in space with an ID. More...
 
struct  Path
 A collection of nodes that form a path. More...
 
struct  PathMember
 The ID of a node, and the cost cost to the node after it. More...
 
struct  Subgraph
 A Subgraph consists of a parent Node m_parent and a container of Edge m_edges such that all Edge in m_edges extend from m_parent. More...
 

Typedefs

using EdgeMatrix = Eigen::SparseMatrix< float, 1 >
 The type of matrix the graph uses internally. More...
 
using TempMatrix = Eigen::Map< const EdgeMatrix >
 A mapped matrix of EdgeMatrix. Only owns pointers to memory. More...
 

Enumerations

enum  STEP {
  NOT_CONNECTED = 0 , NONE = 1 , UP = 2 , DOWN = 3 ,
  OVER = 4
}
 Describes the type of step an edge connects to. More...
 
enum class  COST_AGGREGATE : int { SUM = 0 , AVERAGE = 1 , COUNT = 2 }
 Methods of aggregating the costs for edges for each node in the graph. More...
 
enum class  Direction : int { INCOMING = 0 , OUTGOING = 1 , BOTH = 2 }
 Node to use for calculating the cost of an edge when converting node attributes to edge costs. More...
 
enum  NODE_TYPE { GRAPH = 0 , POI = 1 , OTHER = 2 }
 The type of node this is. More...
 

Functions

template<typename desired_type , typename numeric_type >
constexpr desired_type DivideBy1 (numeric_type n)
 Cast a value to the specific type and divide 1 by it. More...
 
float roundhf (float f, float p=FLOAT_PRECISION, float r=ROUNDING_PRECISION)
 Round a float to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal. More...
 
float trunchf (float f, float p=1000.0, float r=0.001)
 Truncate a float to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal. More...
 
template<typename numeric_type >
numeric_type roundhf_tail (numeric_type f, int precision)
 round a number twice, once at the precision+1, and again at the precision This method is to fix cases in which the precision to round to is 4, and the following number is 9. More...
 
template<typename numeric_type >
constexpr numeric_type roundhf_tmp (numeric_type f, numeric_type p, numeric_type r)
 round a number to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal. More...
 
template<typename desired_type , typename numeric_type >
constexpr desired_type roundhf_tmp (numeric_type f, numeric_type p)
 Round a number to the nearest value to itself at a specific precision. More...
 
template<typename desired_type , typename numeric_type >
constexpr desired_type roundhf_tmp (numeric_type f)
 Round a number to the global rounding precision. More...
 
template<typename numeric_type >
constexpr numeric_type trunchf_tmp (numeric_type f, numeric_type p, numeric_type r)
 truncate a number to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal. More...
 
template<typename desired_type , typename numeric_type >
constexpr desired_type trunchf_tmp (numeric_type f, numeric_type p)
 Truncate a number to the nearest value not greater than itself at a specific precision. More...
 
template<typename desired_type , typename numeric_type >
constexpr desired_type trunchf_tmp (numeric_type f)
 Truncate a number to the nearest value not greater than itself at a specific precision. More...
 
void Normalize (std::array< float, 3 > &vector)
 

Variables

constexpr float ROUNDING_PRECISION = 0.0001f
 Minimum value that can be represented in DHART_API. More...
 
constexpr float FLOAT_PRECISION = 10000.0f
 Used to convert to a given precision (avoids division) More...
 
constexpr float GROUND_OFFSET = 0.001f
 Offset to be used for offsetting from a polygon when performing checks. More...
 

Detailed Description

Contains standard fundamental data structures for representing space used throughout DHARTAPI.

Remarks
The datatypes in the SpatialStructures Namespace are used throughout the DHARTAPI library. For example, the HF::GraphGenerator and HF::VisibilityGraph both produce a Graph as output, allowing for the code to manage the Graph's internal CSR to be centralized in a single location.

Class Documentation

◆ HF::SpatialStructures::Subgraph

struct HF::SpatialStructures::Subgraph

A Subgraph consists of a parent Node m_parent and a container of Edge m_edges such that all Edge in m_edges extend from m_parent.

Definition at line 364 of file graph.h.

+ Collaboration diagram for HF::SpatialStructures::Subgraph:
Class Members
vector< Edge > m_edges The edges that extend from m_parent.
Node m_parent The parent node from which all Edge in m_edges extend.

Typedef Documentation

◆ EdgeMatrix

using HF::SpatialStructures::EdgeMatrix = typedef Eigen::SparseMatrix<float, 1>

The type of matrix the graph uses internally.

Definition at line 21 of file graph.h.

◆ TempMatrix

using HF::SpatialStructures::TempMatrix = typedef Eigen::Map<const EdgeMatrix>

A mapped matrix of EdgeMatrix. Only owns pointers to memory.

Definition at line 22 of file graph.h.

Enumeration Type Documentation

◆ COST_AGGREGATE

enum class HF::SpatialStructures::COST_AGGREGATE : int
strong

Methods of aggregating the costs for edges for each node in the graph.

See also
Graph.AggregateGraph() for details on how to use this enum.
Enumerator
SUM 

Add the cost of all edges.

AVERAGE 

Average the cost of all edges.

COUNT 

Count how many edges this node has.

Definition at line 28 of file graph.h.

◆ Direction

enum class HF::SpatialStructures::Direction : int
strong

Node to use for calculating the cost of an edge when converting node attributes to edge costs.

Enumerator
INCOMING 
OUTGOING 
BOTH 

Definition at line 39 of file graph.h.

◆ NODE_TYPE

The type of node this is.

Remarks

This was primarially used in the previous codebase to differentiate the different types of nodes in the database. Since the database is not implemented here, this goes entirely unused. May be useful in the future.

Enumerator
GRAPH 

This node is a graph node.

POI 

POI is 'point of interest'.

OTHER 

This node doesn't belong in any other category.

Definition at line 29 of file node.h.

◆ STEP

Describes the type of step an edge connects to.

Enumerator
NOT_CONNECTED 

No connection between parent and child.

NONE 

Parent and child are on the same plane and no step is required.

UP 

A step up is required to get from parent to child.

DOWN 

A step down is required to get from parent to child.

OVER 

A step over something is required to get from parent to child.

Definition at line 15 of file Edge.h.

Function Documentation

◆ DivideBy1()

template<typename desired_type , typename numeric_type >
constexpr desired_type HF::SpatialStructures::DivideBy1 ( numeric_type  n)
inlineconstexpr

Cast a value to the specific type and divide 1 by it.

Template Parameters
numeric_typeType of number to divide 1 by
desired_typeType to cast to and return.
Parameters
nNumber to divide 1 by.
Returns
1/n

Definition at line 44 of file Constants.h.

◆ Normalize()

void HF::SpatialStructures::Normalize ( std::array< float, 3 > &  vector)

Definition at line 123 of file node.cpp.

Referenced by HF::SpatialStructures::Node::directionTo().

+ Here is the caller graph for this function:

◆ roundhf()

float HF::SpatialStructures::roundhf ( float  f,
float  p = FLOAT_PRECISION,
float  r = ROUNDING_PRECISION 
)

Round a float to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal.

Parameters
fThe desired float to round.
pThe override of FLOAT_PRECISION (e.g., 10000.0f)
rThe override of ROUNDING_PRECISION (e.g., 0.0001f)
Returns
f rounded to the nearest rounding_precision.
// be sure to #include "Constants.h" std::round from the cmath library is used in
// roundhf. Precision is to the nearest ten-thousandth
const float my_pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;
float rounded = HF::SpatialStructures::roundhf(my_pi); // rounded == 3.1416
float roundhf(float f, float p=FLOAT_PRECISION, float r=ROUNDING_PRECISION)
Round a float to the nearest precision defined globally. The global values can be overridden with opt...
Definition: Constants.cpp:14

Definition at line 14 of file Constants.cpp.

◆ roundhf_tail()

template<typename numeric_type >
numeric_type HF::SpatialStructures::roundhf_tail ( numeric_type  f,
int  precision 
)

round a number twice, once at the precision+1, and again at the precision This method is to fix cases in which the precision to round to is 4, and the following number is 9.

\notes It may also be more simply solved by adding some small epsilon before rounding

Template Parameters
return_typeType of number to round. Can be float, double, or long double.
Parameters
fValue to round.
precisionNumber of digits to round to

Definition at line 89 of file Constants.h.

◆ roundhf_tmp() [1/3]

template<typename desired_type , typename numeric_type >
constexpr desired_type HF::SpatialStructures::roundhf_tmp ( numeric_type  f)
inlineconstexpr

Round a number to the global rounding precision.

Template Parameters
desired_typeType to use and be returned by this calculation .All values will be converted to this type before any operations are performed.
numeric_typeType of number to truncate. Can be float, double, or long double.
Parameters
fThe number to round.
Returns
f rounded at ROUNDING_PRECISION.

Definition at line 148 of file Constants.h.

References roundhf_tmp(), and ROUNDING_PRECISION.

+ Here is the call graph for this function:

◆ roundhf_tmp() [2/3]

template<typename desired_type , typename numeric_type >
constexpr desired_type HF::SpatialStructures::roundhf_tmp ( numeric_type  f,
numeric_type  p 
)
inlineconstexpr

Round a number to the nearest value to itself at a specific precision.

Template Parameters
desired_typeType to use and be returned by this calculation. All values will be converted to this type before any operations are performed.
numeric_typeType of number to round. Can be float, double, or long double.
Parameters
fThe number to round.
rPrecision to round to I.E. 0.0001 will round up to the 4th decimal place
Returns
f rounded to the nearest point specified in r.

Definition at line 133 of file Constants.h.

References roundhf_tmp().

+ Here is the call graph for this function:

◆ roundhf_tmp() [3/3]

template<typename numeric_type >
constexpr numeric_type HF::SpatialStructures::roundhf_tmp ( numeric_type  f,
numeric_type  p,
numeric_type  r 
)
inlineconstexpr

round a number to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal.

Template Parameters
numeric_typeType of number to round. Can be float, double, or long double.
Parameters
fThe desired value to round.
pThe unit precision to round (e.g, 1000.0f)
rThe override of the conversion back (e.g., 0.001f)
Returns
F rounded to the specified precision.

Definition at line 114 of file Constants.h.

References roundhf_tmp().

Referenced by roundhf_tmp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trunchf()

float HF::SpatialStructures::trunchf ( float  f,
float  p = 1000.0,
float  r = 0.001 
)

Truncate a float to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal.

Parameters
fThe desired float to truncate.
pThe unit precision to truncate (Default, 1000.0f)
rThe override of the conversion back (e.g., 0.001f)
Returns
f rounded to the nearest rounding_precision.

Definition at line 20 of file Constants.cpp.

◆ trunchf_tmp() [1/3]

template<typename desired_type , typename numeric_type >
constexpr desired_type HF::SpatialStructures::trunchf_tmp ( numeric_type  f)
inlineconstexpr

Truncate a number to the nearest value not greater than itself at a specific precision.

Template Parameters
desired_typeType to useand be returned by this calculation.All values will be converted to this type before any operations are performed.
numeric_typeType of number to truncate.Can be float, double, or long double.
Parameters
fThe number to truncate.
Returns
f truncated at ROUNDING_PRECISION.

Definition at line 204 of file Constants.h.

References ROUNDING_PRECISION, and trunchf_tmp().

+ Here is the call graph for this function:

◆ trunchf_tmp() [2/3]

template<typename desired_type , typename numeric_type >
constexpr desired_type HF::SpatialStructures::trunchf_tmp ( numeric_type  f,
numeric_type  p 
)
inlineconstexpr

Truncate a number to the nearest value not greater than itself at a specific precision.

Template Parameters
desired_typeType to useand be returned by this calculation.All values will be converted to this type before any operations are performed.
numeric_typeType of number to truncate. Can be float, double, or long double.
Parameters
fThe number to truncate.
rPrecision to truncate at I.E. 0.0001 will discard all values past the 4th decimal place
Returns
f truncated at the point specified in r.

Definition at line 189 of file Constants.h.

References trunchf_tmp().

+ Here is the call graph for this function:

◆ trunchf_tmp() [3/3]

template<typename numeric_type >
constexpr numeric_type HF::SpatialStructures::trunchf_tmp ( numeric_type  f,
numeric_type  p,
numeric_type  r 
)
inlineconstexpr

truncate a number to the nearest precision defined globally. The global values can be overridden with optional parameters p and r. If r is 0.01, p must be 100.0, meaning there should be one more 0 between the decimal.

Template Parameters
numeric_typeType of number to truncate. Can be float, double, or long double.
Parameters
fThe desired float to truncate.
pThe unit precision to truncate (Default, 1000.0f)
rThe override of the conversion back (e.g., 0.001f)
Returns
f truncated to the nearest rounding_precision.

Definition at line 170 of file Constants.h.

References trunchf_tmp().

Referenced by trunchf_tmp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ FLOAT_PRECISION

constexpr float HF::SpatialStructures::FLOAT_PRECISION = 10000.0f
constexpr

Used to convert to a given precision (avoids division)

Definition at line 31 of file Constants.h.

◆ GROUND_OFFSET

constexpr float HF::SpatialStructures::GROUND_OFFSET = 0.001f
constexpr

Offset to be used for offsetting from a polygon when performing checks.

Definition at line 32 of file Constants.h.

◆ ROUNDING_PRECISION

constexpr float HF::SpatialStructures::ROUNDING_PRECISION = 0.0001f
constexpr

Minimum value that can be represented in DHART_API.

All rounding operations in HF::SpatialStructures will use this constant in rounding operations.

Definition at line 30 of file Constants.h.

Referenced by HF::VisibilityGraph::HeightCheck(), HF::SpatialStructures::CostAlgorithms::is_perpendicular(), HF::SpatialStructures::Node::operator==(), HF::SpatialStructures::PathMember::operator==(), roundhf_tmp(), and trunchf_tmp().