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

Path class for manipulating and analyzing paths in 2D space. More...

Go to the source code of this file.

Classes

class  hmap::Path
 Represents an ordered set of points in 2D, forming a polyline (open or closed). More...
 

Namespaces

namespace  hmap
 

Functions

Path hmap::bezier (const Path &path, float curvature_ratio=0.3f, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
 Smooth the path using Bezier curves.
 
Path hmap::bezier_round (const Path &path, float curvature_ratio=0.3f, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
 Smooth the path using Bezier curves (alternative method).
 
Path hmap::bspline (const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
 Smooth the path using B-Spline curves.
 
Path hmap::catmullrom (const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
 Smooth the path using Catmull-Rom curves.
 
Path hmap::decasteljau (const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
 Smooth the path using De Casteljau curves.
 
Path hmap::decimate_vw (const Path &path, int n_points_target=3)
 Simplifies the current path using the Visvalingam-Whyatt algorithm.
 
Path hmap::fractalize (const Path &path, int iterations, uint seed, float sigma=0.2f, int orientation=0, float persistence=1.f, Array *p_control_field=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
 Applies fractalization to the path by adding points and randomly displacing their positions.
 
Path hmap::inflate (const Path &path, float strength, bool resample=true)
 Inflate (offset) a path along its normals using curvature.
 
Path hmap::meanderize (const Path &path, float ratio, float noise_ratio=0.1f, uint seed=1, int iterations=1, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE)
 Add "meanders" to the path.
 
Array hmap::path_sdf_to_array (const Path &path, glm::ivec2 shape, glm::vec4 bbox_array={0.f, 1.f, 0.f, 1.f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr)
 Compute a distance field from a point path.
 
Path hmap::remove_geometric_loops (const Path &path)
 Removes geometric loops in a 2D path caused by self-intersections.
 
Path hmap::smooth (const Path &path, int navg=1, float averaging_intensity=1.f, float inertia=0.f)
 Applies a smoothing operation to the path points using a moving average filter.
 
bool hmap::assert_start_end_points (const Path &path1, const Path &path2, float tol=1e-6f, bool verbose=false)
 Asserts that the start and end points of two paths are within a specified tolerance.
 
float hmap::chamfer_distance (const Path &a, const Path &b)
 Calculate the chamfer distance between two paths.
 
bool hmap::has_duplicates (const Path &path, float tol=1e-6f)
 Check if a path contains duplicate points within a given tolerance.
 

Detailed Description

Path class for manipulating and analyzing paths in 2D space.

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

This file defines the Path class, which extends the Cloud class to provide functionalities specific to paths. The Path class includes methods for creating, manipulating, and analyzing paths, including smoothing the path with various curves, resampling, and performing operations like meandering and fractalizing.

Version
0.1
Date
2023-06-18

This software is distributed under the terms of the GNU General Public License. The full license is in the file LICENSE, distributed with this software.