HighMap library (C++)
Loading...
Searching...
No Matches
shortest_path.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
13#pragma once
14
15#include "highmap/array.hpp"
16#include "highmap/boundary.hpp"
18
19namespace hmap
20{
21
54Path dijkstra(const Path &path,
55 const Array &array,
56 glm::vec4 bbox,
57 float elevation_ratio = 0.f,
58 float distance_exponent = 0.5f,
59 float upward_penalization = 1.f,
60 Array *p_mask_nogo = nullptr);
61
86Path find_cut_path_dijkstra(const Array &z,
87 DomainBoundary start,
89 float dijk_elevation_ratio = 0.9f,
90 float dijk_distance_exponent = 2.f,
91 float dijk_upward_penalization = 100.f,
92 uint seed = 0,
93 bool favor_boundary_center = true,
94 bool favor_lower_elevation = true,
95 bool favor_sinks = true);
96
119Path find_cut_path_midpoint(const Array &z,
120 DomainBoundary start,
121 DomainBoundary end,
122 uint seed,
123 float offset_ratio = 0.2f,
124 int steps = 16,
125 bool favor_boundary_center = true,
126 bool favor_lower_elevation = true,
127 bool favor_sinks = true);
128
170void find_path_dijkstra(const Array &z,
171 glm::ivec2 ij_start,
172 glm::ivec2 ij_end,
173 std::vector<int> &i_path,
174 std::vector<int> &j_path,
175 float elevation_ratio = 0.1f,
176 float distance_exponent = 2.f,
177 float upward_penalization = 1.f,
178 const Array *p_mask_nogo = nullptr);
179
180void find_path_dijkstra(const Array &z,
181 glm::ivec2 ij_start,
182 std::vector<glm::ivec2> ij_end_list,
183 std::vector<std::vector<int>> &i_path_list,
184 std::vector<std::vector<int>> &j_path_list,
185 float elevation_ratio = 0.1f,
186 float distance_exponent = 2.f,
187 float upward_penalization = 1.f,
188 const Array *p_mask_nogo = nullptr);
189
212std::vector<glm::ivec2> find_path_midpoint(const Array &z,
213 glm::ivec2 ij_start,
214 glm::ivec2 ij_end,
215 float offset_ratio = 0.5f,
216 int max_it = 0,
217 int steps = 16);
218
219} // namespace hmap
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
unsigned int uint
Definition array.hpp:14
Header file for boundary condition functions and utilities.
Definition algebra.hpp:23
DomainBoundary
Describes which domain boundary.
Definition boundary.hpp:43
Path find_cut_path_dijkstra(const Array &z, DomainBoundary start, DomainBoundary end, float dijk_elevation_ratio=0.9f, float dijk_distance_exponent=2.f, float dijk_upward_penalization=100.f, uint seed=0, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true)
Find a Dijkstra-based cut path between two domain boundaries.
Definition find_cut_path.cpp:11
Path find_cut_path_midpoint(const Array &z, DomainBoundary start, DomainBoundary end, uint seed, float offset_ratio=0.2f, int steps=16, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true)
Generate a stochastic cut path using midpoint displacement.
Definition find_cut_path.cpp:70
Path dijkstra(const Path &path, const Array &array, glm::vec4 bbox, float elevation_ratio=0.f, float distance_exponent=0.5f, float upward_penalization=1.f, Array *p_mask_nogo=nullptr)
Divide the path by adding points based on the lowest elevation difference between each pair of edge e...
Definition dijsktra_path.cpp:12
std::vector< glm::ivec2 > find_path_midpoint(const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, float offset_ratio=0.5f, int max_it=0, int steps=16)
Compute a path between two points using iterative midpoint refinement.
Definition find_path_midpoint.cpp:73
void find_path_dijkstra(const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, std::vector< int > &i_path, std::vector< int > &j_path, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=1.f, const Array *p_mask_nogo=nullptr)
Finds the path with the lowest elevation and elevation difference between two points in a 2D array us...
Definition dijsktra.cpp:141
Path class for manipulating and analyzing paths in 2D space.