96 Path(std::vector<float> x, std::vector<float> y,
bool closed =
false)
109 std::vector<float> y,
110 std::vector<float> v,
134 void bezier(
float curvature_ratio = 0.3f,
int edge_divisions = 10);
154 void bezier_round(
float curvature_ratio = 0.3f,
int edge_divisions = 10);
179 void bspline(
int edge_divisions = 10);
317 float elevation_ratio = 0.f,
318 float distance_exponent = 0.5f,
319 float upward_penalization = 1.f,
320 Array *p_mask_nogo =
nullptr);
379 float persistence = 1.f,
380 Array *p_control_field =
nullptr,
430 std::vector<float>
get_x()
const;
443 std::vector<float>
get_xy()
const;
454 std::vector<float>
get_y()
const;
498 float noise_ratio = 0.1f,
501 int edge_divisions = 10);
721 float averaging_intensity = 1.f,
722 float inertia = 0.f);
751 void to_array(Array &array, Vec4<float> bbox,
bool filled =
false)
const;
785 Array *p_noise_x =
nullptr,
786 Array *p_noise_y =
nullptr,
787 Vec4<float> bbox_array = {0.f, 1.f, 0.f, 1.f});
802 void to_png(std::string fname, Vec2<int> shape = {512, 512});
847 int flattening_radius = 16,
848 bool force_downhill =
false,
849 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f},
883 const std::vector<Path> &path_list,
884 float riverbank_talus,
886 int merging_width = 0,
888 float riverbed_talus = 0.f,
889 float noise_ratio = 0.9f,
891 Array *p_mask =
nullptr);
895 float riverbank_talus,
897 int merging_width = 0,
899 float riverbed_talus = 0.f,
900 float noise_ratio = 0.9f,
902 Array *p_mask =
nullptr);
unsigned int uint
Definition array.hpp:14
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
Represents a collection of unordered points in 2D space.
Definition cloud.hpp:55
std::vector< Point > points
Points of the cloud.
Definition cloud.hpp:57
Represents an ordered set of points in 2D, forming a polyline (open or closed).
Definition path.hpp:49
Path(std::vector< float > x, std::vector< float > y, std::vector< float > v, bool closed=false)
Construct a new Path object based on x, y coordinates, and values. Initializes a path with the specif...
Definition path.hpp:108
void bspline(int edge_divisions=10)
Smooth the path using B-Spline curves.
Definition path.cpp:107
std::vector< float > get_xy() const
Get the coordinates of the points as a single vector.
Definition path.cpp:400
void meanderize(float ratio, float noise_ratio=0.1f, uint seed=1, int iterations=1, int edge_divisions=10)
Add "meanders" to the path.
Definition path.cpp:447
Path(int npoints, uint seed, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f}, bool closed=false)
Construct a new Path object with random positions and values. Initializes a path with a specified num...
Definition path.hpp:73
void to_png(std::string fname, Vec2< int > shape={512, 512})
Export path as PNG image file.
Definition path.cpp:895
void fractalize(int iterations, uint seed, float sigma=0.3f, int orientation=0, float persistence=1.f, Array *p_control_field=nullptr, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Applies fractalization to the path by adding points and randomly displacing their positions.
Definition path.cpp:300
bool closed
Defines whether the path is closed or open. If true, the path is closed, forming a loop....
Definition path.hpp:55
Path(std::vector< Point > points, bool closed=false)
Construct a new Path object based on a list of points. Initializes a path with the specified points a...
Definition path.hpp:85
void to_array(Array &array, Vec4< float > bbox, bool filled=false) const
Project path points to an array.
Definition path.cpp:810
std::vector< float > get_arc_length()
Get the arc length of the path.
Definition path.cpp:356
void catmullrom(int edge_divisions=10)
Smooth the path using Catmull-Rom curves.
Definition path.cpp:119
void enforce_monotonic_values(bool decreasing=true)
Enforces monotonicity on the values of the points in the path.
Definition path.cpp:427
void decimate_cfit(int n_points_target=3)
Simplifies the current path using a curvature preserving algorithm.
Definition path.cpp:155
void bezier(float curvature_ratio=0.3f, int edge_divisions=10)
Smooth the path using Bezier curves.
Definition path.cpp:25
void dijkstra(Array &array, Vec4< float > 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 path.cpp:216
std::vector< float > get_values() const
Get the values assigned to the points on the path.
Definition path.cpp:380
float sdf_angle_open(float x, float y)
Return the angle of the closest edge to the point (x, y), assuming an open path.
Definition path.cpp:658
float sdf_elevation_open(float x, float y, float slope)
Return the elevation value at (x, y) away from the path based on a downslope slope,...
Definition path.cpp:722
void divide()
Divide the path by adding a point between each pair of consecutive points.
Definition path.cpp:275
void decasteljau(int edge_divisions=10)
Smooth the path using De Casteljau curves.
Definition path.cpp:138
Path(bool closed=false)
Construct a new Path object with default properties. Initializes an empty path with the closed proper...
Definition path.hpp:62
void subsample(int step)
Subsample the path by keeping only every n-th point.
Definition path.cpp:794
void bezier_round(float curvature_ratio=0.3f, int edge_divisions=10)
Smooth the path using Bezier curves (alternative method).
Definition path.cpp:65
void reverse()
Reverse the order of points in the path.
Definition path.cpp:625
std::vector< float > get_y() const
Get the y coordinates of the points on the path.
Definition path.cpp:417
void smooth(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.
Definition path.cpp:759
std::vector< float > get_x() const
Get the x coordinates of the points on the path.
Definition path.cpp:390
void resample(float delta)
Resample the path to achieve an approximately constant distance between points.
Definition path.cpp:556
float sdf_closed(float x, float y)
Return the signed distance function value at (x, y), assuming a closed path.
Definition path.cpp:681
void decimate_vw(int n_points_target=3)
Simplifies the current path using the Visvalingam-Whyatt algorithm.
Definition path.cpp:184
void resample_uniform()
Resample the path to achieve fairly uniform distance between consecutive points.
Definition path.cpp:604
float sdf_open(float x, float y)
Return the value of the signed distance function at (x, y), assuming an open path.
Definition path.cpp:741
void reorder_nns(int start_index=0)
Reorder points using a nearest neighbor search.
Definition path.cpp:510
void clear()
Clear the path data.
Definition path.cpp:132
Path(std::vector< float > x, std::vector< float > y, bool closed=false)
Construct a new Path object based on x and y coordinates. Initializes a path with the specified x and...
Definition path.hpp:96
float sdf_elevation_closed(float x, float y, float slope)
Return the elevation value at (x, y) away from the path based on a downslope slope,...
Definition path.cpp:703
std::vector< float > get_cumulative_distance()
Get the cumulative distance of the path.
Definition path.cpp:365
float sdf_angle_closed(float x, float y)
Return the angle of the closest edge to the point (x, y), assuming a closed path.
Definition path.cpp:630
Array to_array_sdf(Vec2< int > shape, Vec4< float > bbox, Array *p_noise_x=nullptr, Array *p_noise_y=nullptr, Vec4< float > bbox_array={0.f, 1.f, 0.f, 1.f})
Return an array filled with the signed distance function to the path.
Definition path.cpp:858
Definition of the Cloud class for manipulating sets of 2D points.
Definition algebra.hpp:28
void dig_river(Array &z, const std::vector< Path > &path_list, float riverbank_talus, int river_width=0, int merging_width=0, float depth=0.f, float riverbed_talus=0.f, float noise_ratio=0.9f, uint seed=0, Array *p_mask=nullptr)
Modifies the elevation array to carve a river along a specified path.
Definition path.cpp:956
void dig_path(Array &z, Path &path, int width=1, int decay=2, int flattening_radius=16, bool force_downhill=false, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f}, float depth=0.f)
Dig a path on a heightmap.
Definition path.cpp:906
Array step(Vec2< int > shape, float angle, float slope, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, Vec2< float > center={0.5f, 0.5f}, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Return a step function (Heaviside with an optional talus slope at the transition).
Definition primitives.cpp:272
Array slope(Vec2< int > shape, float angle, float slope, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, Vec2< float > center={0.5f, 0.5f}, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Return an array corresponding to a slope with a given overall.
Definition primitives.cpp:249
Vec4 class for basic manipulation of 4D vectors.
Definition algebra.hpp:564