9#define _USE_MATH_DEFINES
27 return degrees * (M_PI / 180);
31 return radians * (180 / M_PI);
50 double n1 = child[0] - parent[0];
51 double n2 = child[1] - parent[1];
52 double n3 = child[2] - parent[2];
61 double numerator = std::abs(n3);
64 double denom = std::sqrt(std::pow(n1, 2) + std::pow(n2, 2) + std::pow(n3, 2));
74 double res = std::asin(numerator/denom);
77 if (child[2] > parent[2]){
89 if (!std::isfinite(slope))
98 std::vector<EdgeSet> edge_set;
102 std::vector<Edge> edge_list = sg.
m_edges;
106 std::vector<IntEdge> children(edge_list.size());
107 auto it_children = children.begin();
109 for (
Edge link_a : edge_list) {
113 const auto dir = parent_node.
directionTo(link_a.child);
114 const auto magnitude = parent_node.
distanceTo(link_a.child);
134 const double g = std::clamp(std::tan(
to_radians(slope)), -0.4, 0.4);
137 * (std::pow(g, 5)) - 58.7
138 * (std::pow(g, 4)) - 76.8
139 * (std::pow(g, 3)) + 51.9
140 * (std::pow(g, 2)) + 19.6
147 double expenditure = e * magnitude;
150 IntEdge ie = { link_a.
child.id,
static_cast<float>(expenditure) };
154 *(it_children++) = ie;
157 EdgeSet es = { parent_node.
id, children };
164 std::vector<Node> nodes = g.
Nodes();
168 std::vector<EdgeSet> result(nodes.size());
169 auto it_result = result.begin();
171 for (
Node parent_node : nodes) {
183 *(it_result++) = energy_expenditures;
192 std::vector<IntEdge> result;
195 std::vector<Edge> edges = sg.
m_edges;
197 for (
Edge edge_a : edges) {
199 Node child_node_a = edge_a.child;
200 float edge_data_a = edge_a.score;
220 std::vector<Edge> perpendicular_edges = GetPerpendicularEdges<2>(sg, child_node_a);
223 float cross_slope = 0.0;
228 switch (perpendicular_edges.size()) {
234 weight = edge_data_a;
241 a_z = child_node_a.
z;
244 b_z = perpendicular_edges[0].child.z;
246 cross_slope = std::abs(a_z - b_z);
249 weight = cross_slope + perpendicular_edges[0].score;
256 a_z = child_node_a.
z;
259 b_z = perpendicular_edges[0].child.z;
262 c_z = perpendicular_edges[1].child.z;
264 cross_slope = std::abs(b_z - c_z);
267 weight = std::abs(b_z - c_z) + perpendicular_edges[0].score;
276 IntEdge ie = { child_node_a.
id, weight };
277 result.push_back(ie);
285 std::vector<Node> nodes = g.
Nodes();
289 std::vector<std::vector<IntEdge>> result(nodes.size());
290 auto it_result = result.begin();
292 for (
Node parent_node : nodes) {
304 *(it_result++) = cross_slopes;
Contains definitions for the HF::SpatialStructures namespace.
Contains implementation for the HF::SpatialStructures::CostAlgorithms namespace.
Contains definitions for the Graph class.
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.
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)
A connection to a child node.
A lighter version of Edge that contains an ID instead of a full node object..
int child
Identifier of child node.
A collection of edges and a parent.
A Graph of nodes connected by edges that supports both integers and HF::SpatialStructures::Node.
Subgraph GetSubgraph(const Node &parent_node, const std::string &cost_type="") const
Retrieves a Subgraph using a Node.
std::vector< Node > Nodes() const
Get a list of nodes from the graph sorted by ID.
A point in space with an ID.
float z
Cartesian coordinates x, y, z.
float distanceTo(const Node &n2) const
Calculate the distance between this node and n2.
std::array< float, 3 > directionTo(const Node &n2) const
Get the direction between this node and another node