HighMap library (C++)
Loading...
Searching...
No Matches
shortest_path.hpp File Reference

Implements shortest path algorithms including Dijkstra's method for 2D array data representation. More...

Go to the source code of this file.

Namespaces

namespace  hmap

Functions

Path hmap::dijkstra (const Path &path, const Array &array, const UvRect &uv_rect, float elevation_ratio=0.f, float distance_exponent=0.5f, float upward_penalization=0.1f, Array *p_mask_nogo=nullptr)
 Divide the path by adding points based on the lowest elevation difference between each pair of edge endpoints.
Path hmap::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, std::uint32_t seed=0, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, bool favor_domain_center=false)
 Find a Dijkstra-based cut path between two domain boundaries.
Path hmap::find_cut_path_dijkstra (const Array &z, DomainBoundary start, DomainBoundary end, std::uint32_t seed, size_t control_points_count=2048, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, bool favor_domain_center=false, const UvTile &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
 Generate a cut path across a heightmap using a random triangular mesh and Dijkstra shortest path search (tileable).
Path hmap::find_cut_path_midpoint (const Array &z, DomainBoundary start, DomainBoundary end, std::uint32_t seed, float offset_ratio=0.2f, int steps=16, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, const UvTile &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
 Generate a stochastic cut path using midpoint displacement.
Path hmap::find_cut_path_multiscale (const Array &z, DomainBoundary start, DomainBoundary end, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float dijk_elevation_ratio=0.9f, float dijk_distance_exponent=2.f, float dijk_upward_penalization=100.f, std::uint32_t seed=0, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, bool use_astar=false, bool smooth_path=false)
 Find a fast coarse-to-fine multiscale cut path between two domain boundaries.
void hmap::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=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr)
 Finds the path with the lowest elevation and elevation difference between two points in a 2D array using Dijkstra's algorithm.
void hmap::find_path_dijkstra (const Array &z, glm::ivec2 ij_start, std::vector< glm::ivec2 > ij_end_list, std::vector< std::vector< int > > &i_path_list, std::vector< std::vector< int > > &j_path_list, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr)
Path hmap::find_path_dijkstra (const Array &z, glm::vec2 start, glm::vec2 end, std::uint32_t seed, size_t control_points_count=2048, bool favor_domain_center=false, const UvTile &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
 Generate a path between two points across a heightmap using a random triangular mesh and Dijkstra shortest path search (tileable).
std::vector< glm::ivec2 > hmap::find_path_dijkstra (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr)
 Overload of find_path_dijkstra returning a vector of grid indices.
Path hmap::find_path_dijkstra (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, const UvRect &uv_rect, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr)
 Overload of find_path_dijkstra returning a Path mapped to a bounding box with point values holding sampled terrain elevations.
std::vector< glm::ivec2 > hmap::find_path_midpoint (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, float offset_ratio=0.2f, int max_it=0, int steps=16)
 Compute a path between two points using iterative midpoint refinement.
void hmap::find_path_midpoint (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, std::vector< int > &i_path, std::vector< int > &j_path, float offset_ratio=0.2f, int max_it=0, int steps=16)
 Overload of find_path_midpoint returning path indices in i and j vectors.
Path hmap::find_path_midpoint (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, const UvRect &uv_rect, float offset_ratio=0.2f, int max_it=0, int steps=16)
 Overload of find_path_midpoint returning a Path mapped to a bounding box with point values holding sampled terrain elevations.
void hmap::find_path_multiscale (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, std::vector< int > &i_path, std::vector< int > &j_path, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, bool use_astar=false, bool smooth_path=false)
 Finds a shortest path on a 2D grid using a fast coarse-to-fine multiscale approach.
std::vector< glm::ivec2 > hmap::find_path_multiscale (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, bool use_astar=false, bool smooth_path=false)
 Overload of find_path_multiscale returning a vector of grid indices.
Path hmap::find_path_multiscale (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, const UvRect &uv_rect, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, bool use_astar=false, bool smooth_path=false)
 Overload of find_path_multiscale returning a Path object mapped to a bounding box, with point values containing the elevation sampled from the heightmap.

Detailed Description

Implements shortest path algorithms including Dijkstra's method for 2D array data representation.

Author
Otto Link (otto..nosp@m.link.nosp@m..bv@g.nosp@m.mail.nosp@m..com)