9#ifndef COST_ALGORITHMS_H
10#define COST_ALGORITHMS_H
93 template <
size_t dimension,
typename float_precision =
float>
95 float_precision sum = 0;
97 for (
size_t i = 0; i < dimension; i++) {
98 float_precision difference = point_b[i] - point_a[i];
99 sum += std::pow(difference, 2.0);
102 return std::sqrt(sum);
131 template <
size_t dimension,
typename float_precision =
float>
132 float_precision
dot_product(float_precision vec_U[], float_precision vec_V[]) {
133 float_precision sum = 0;
135 for (
size_t i = 0; i < dimension; i++) {
136 sum += vec_U[i] * vec_V[i];
168 template <
size_t dimension,
typename float_precision =
float>
179 return std::abs(dot_product<dimension, float_precision>(vec_U, vec_V))
230 template <
size_t dimension,
typename float_precision =
float>
232 std::vector<Edge> perpendicular_edges;
237 for (
Edge edge_b : edges) {
238 Node child_node_b = edge_b.child;
248 if (child_node_a != child_node_b) {
265 auto vector_a = parent_node.
directionTo(child_node_a);
266 auto vector_b = parent_node.directionTo(child_node_b);
268 if (is_perpendicular<dimension, float_precision>(vector_a.data(), vector_b.data())) {
271 perpendicular_edges.push_back(edge_b);
282 return perpendicular_edges;
Contains definitions for the HF::SpatialStructures namespace.
Contains standard fundamental data structures for representing space used throughout DHARTAPI.
constexpr float ROUNDING_PRECISION
Minimum value that can be represented in DHART_API.
A Subgraph consists of a parent Node m_parent and a container of Edge m_edges such that all Edge in m...
Node m_parent
The parent node from which all Edge in m_edges extend.
std::vector< Edge > m_edges
The edges that extend from m_parent.
float_precision euclidean_distance(float_precision point_a[], float_precision point_b[])
bool is_perpendicular(float_precision vec_U[], float_precision vec_V[])
std::vector< IntEdge > CalculateCrossSlope(const Subgraph &sg)
EdgeSet CalculateEnergyExpenditure(const Subgraph &sg)
double to_degrees(double radians)
double CalculateSlope(Node &parent, Node &child)
double to_radians(double degrees)
std::vector< Edge > GetPerpendicularEdges(const Subgraph &sg, const Node &child_node_a)
float_precision dot_product(float_precision vec_U[], float_precision vec_V[])
A connection to a child node.
A collection of edges and a parent.
A Graph of nodes connected by edges that supports both integers and HF::SpatialStructures::Node.
A point in space with an ID.
std::array< float, 3 > directionTo(const Node &n2) const
Get the direction between this node and another node