lefer
0.1.0
A C++ library to draw evenly-spaced and non-overlapping curves in a flow field using the Jobard and Lefer (1997) algorithm.
|
Classes | |
class | FlowField |
struct | Point |
class | Curve |
struct | DensityCell |
class | DensityGrid |
class | SeedPointsQueue |
Functions | |
double | distance (double x1, double y1, double x2, double y2) |
SeedPointsQueue | collect_seedpoints (Curve *curve, double d_sep) |
Curve | draw_curve (int curve_id, double x_start, double y_start, int n_steps, double step_length, double d_sep, FlowField *flow_field, DensityGrid *density_grid) |
std::vector< Curve > | even_spaced_curves (double x_start, double y_start, int n_curves, int n_steps, int min_steps_allowed, double step_length, double d_sep, FlowField *flow_field, DensityGrid *density_grid) |
std::vector< Curve > | non_overlapping_curves (std::vector< Point > starting_points, int n_steps, int min_steps_allowed, double step_length, double d_sep, FlowField *flow_field, DensityGrid *density_grid) |
SeedPointsQueue lefer::collect_seedpoints | ( | Curve * | curve, |
double | d_sep | ||
) |
double lefer::distance | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2 | ||
) |
Calculate the distance between two points
x1 | the x coordinate of point 1. |
y1 | the y coordinate of point 1. |
x2 | the x coordinate of point 2. |
y2 | the y coordinate of point 2. |
Curve lefer::draw_curve | ( | int | curve_id, |
double | x_start, | ||
double | y_start, | ||
int | n_steps, | ||
double | step_length, | ||
double | d_sep, | ||
FlowField * | flow_field, | ||
DensityGrid * | density_grid | ||
) |
Draw a curve in the flow field.
This function draws a curve in the flow field by starting in a specific point in the field (x_start
and y_start
), and then, it starts to walk through the field, by followinf the direction of the angles it encounters in the field.
For more details check: https://pedro-faria.netlify.app/posts/2024/2024-02-19-flow-even/en/
curve_id | the id of the curve you want to draw. |
x_start | the x coordinate of the starting point from which the function will start to draw your curve. |
y_start | the y coordinate of the starting point from which the function will start to draw your curve. |
n_steps | the number of steps used to draw your curve. |
step_length | the length/distance taken in each step. |
d_sep | the "separation distance", i.e., the amount of distance that each curve must be from neighbouring curves. |
flow_field | a lefer::FlowField that contains the 2D grid of angle values that define your flow field. |
density_grid | the density grid to be used by the algorithm, i.e., a lefer::DensityGrid object. |
std::vector< Curve > lefer::even_spaced_curves | ( | double | x_start, |
double | y_start, | ||
int | n_curves, | ||
int | n_steps, | ||
int | min_steps_allowed, | ||
double | step_length, | ||
double | d_sep, | ||
FlowField * | flow_field, | ||
DensityGrid * | density_grid | ||
) |
Draws multiple evenly-spaced and non-overlapping curves in the flow field.
This function takes a starting point (x_start
and y_start
) in the flow field, and draws a initial curve in the flow field. After that, the function starts a loop process, to derivate n_curves - 1
curves from this initial curve. All the curves that are drawn into the field are derived from this initial curve.
In other words, it is not guaranteed that this function will draw exactly n_curves
curves into the field, because, it might not have enough space for n_curves
curves, considering your current settings. The function will attempt to draw as many curves as possible. As long as they are not overlapping each other, and they are not too close to neighbouring curves, the function will continue to draw curves into the field.
x_start | the x coordinate of the starting point of the initial curve. |
y_start | the y coordinate of the starting point of the initial curve. |
n_curves | the number of curves that the function will attempt to draw from the initial curve. |
n_steps | the number of steps that each curve drawn into the field will have. |
min_steps_allowed | the minimum number of steps allowed for a curve. In other words, every curve that is drawn in the field must have at least min_steps_allowed steps. |
step_length | the length (or distance) taken in each step (usually, you want to set this variable between 1% and 0.1% of the flow field width. |
d_sep | the "separation distance", i.e., the amount of distance that each curve must be from neighbouring curves. |
flow_field | a lefer::FlowField that contains the 2D grid of angle values that define your flow field. |
density_grid | the density grid to be used by the algorithm, i.e., a lefer::DensityGrid object. |
std::vector< Curve > lefer::non_overlapping_curves | ( | std::vector< Point > | starting_points, |
int | n_steps, | ||
int | min_steps_allowed, | ||
double | step_length, | ||
double | d_sep, | ||
FlowField * | flow_field, | ||
DensityGrid * | density_grid | ||
) |
Draws multiple non-overlapping curves in the flow field.
While even_spaced_curves()
checks both the distance from the current curve to neighbouring curves, to ensure an even space between each curve, this function checks only if the current curve is overlapping or not other curves. In other words, you use this function if you care only to draw curves that do not overlap each other.
This function takes a sequence of startings points (starting_points
). For each starting point, this function will attempt to draw a curve from it. So, in this function, you have total control over which points exatly the curves starts from.
It is not guaranteed that this function will draw exactly n_curves
curves into the field, because, it might not have enough space for n_curves
curves, considering your current settings. The function will attempt to draw as many curves as possible. As long as they are not overlapping each other, the function will continue to draw curves into the field.
starting_points | a sequence of lefer::Point objects. Each lefer::Point object should describe a starting point for a single curve. |
n_steps | the number of steps that each curve drawn into the field will have. |
min_steps_allowed | the minimum number of steps allowed for a curve. In other words, every curve that is drawn in the field must have at least min_steps_allowed steps. |
step_length | the length (or distance) taken in each step (usually, you want to set this variable between 1% and 0.1% of the flow field width. |
d_sep | the "separation distance", i.e., the amount of distance that each curve must be from neighbouring curves. |
flow_field | a lefer::FlowField that contains the 2D grid of angle values that define your flow field. |
density_grid | the density grid to be used by the algorithm, i.e., a lefer::DensityGrid object. |