Sequential 2D inverse transform point sampler based on a 2D density array.
More...
#include <inverse_sampler_2d.hpp>
|
| | InverseSampler2D ()=default |
| | InverseSampler2D (const Array &density, std::uint32_t seed=0, const BBox2D &bbox=BBox2D{}) |
| | Constructs an inverse sampler for a 2D density array.
|
| glm::vec2 | sample () |
| | Samples a single point sequentially using the internal RNG.
|
| glm::vec2 | sample (float u, float u2) |
| | Samples a single point with user-provided uniform random numbers.
|
| std::array< std::vector< float >, 2 > | sample (size_t count) |
| | Samples multiple points sequentially.
|
| glm::vec2 | sample (const BBox2D &restricted_bbox) |
| | Samples a single point sequentially within a restricted bounding box.
|
| glm::vec2 | sample (const BBox2D &restricted_bbox, float u, float u2) |
| | Samples a single point within a restricted bounding box with user-provided uniform random numbers.
|
| void | update_region (const Array &updated_array, const glm::ivec2 &range_i, const glm::ivec2 &range_j) |
| | Updates the density in the sub-region [imin, imax] x [jmin, jmax] from another array.
|
| void | update_region (const std::function< float(int i, int j, float current)> &updater, const glm::ivec2 &range_i, const glm::ivec2 &range_j) |
| | Updates the density in the sub-region [imin, imax] x [jmin, jmax] using a modifier function.
|
| void | reset (const Array &density, std::uint32_t seed=0, const BBox2D &bbox=BBox2D{}) |
| | Reinitializes the sampler with a new density array.
|
| const BBox2D & | get_bbox () const |
| | Gets the bounding box.
|
| const Array & | get_density () const |
| | Gets the current density array.
|
| float | get_total_weight () const |
| | Gets the total integrated weight.
|
| void | set_bbox (const BBox2D &bbox) |
| | Sets the bounding box.
|
| void | set_seed (std::uint32_t seed) |
| | Sets the RNG seed.
|
Sequential 2D inverse transform point sampler based on a 2D density array.
Supports generating points one-by-one and dynamically updating density in local bounding box or index sub-regions [imin, imax] x [jmin, jmax].
◆ InverseSampler2D() [1/2]
| hmap::InverseSampler2D::InverseSampler2D |
( |
| ) |
|
|
default |
◆ InverseSampler2D() [2/2]
| hmap::InverseSampler2D::InverseSampler2D |
( |
const Array & | density, |
|
|
std::uint32_t | seed = 0, |
|
|
const BBox2D & | bbox = BBox2D{} ) |
Constructs an inverse sampler for a 2D density array.
- Parameters
-
| density | 2D density array. |
| seed | Random number generator seed. |
| bbox | Bounding box (xmin, xmax, ymin, ymax). Defaults to unit square. |
◆ sample() [1/5]
| glm::vec2 hmap::InverseSampler2D::sample |
( |
| ) |
|
Samples a single point sequentially using the internal RNG.
- Returns
- 2D point coordinates within the bounding box.
◆ sample() [2/5]
| glm::vec2 hmap::InverseSampler2D::sample |
( |
float | u, |
|
|
float | u2 ) |
Samples a single point with user-provided uniform random numbers.
- Parameters
-
| u | Uniform random number in [0, 1) for row selection. |
| u2 | Uniform random number in [0, 1) for column selection. |
- Returns
- 2D point coordinates within the bounding box.
◆ sample() [3/5]
| std::array< std::vector< float >, 2 > hmap::InverseSampler2D::sample |
( |
size_t | count | ) |
|
Samples multiple points sequentially.
- Parameters
-
| count | Number of points to sample. |
- Returns
- A pair of coordinate vectors {x_coords, y_coords}.
◆ sample() [4/5]
| glm::vec2 hmap::InverseSampler2D::sample |
( |
const BBox2D & | restricted_bbox | ) |
|
Samples a single point sequentially within a restricted bounding box.
- Parameters
-
| restricted_bbox | Bounding box {xmin, xmax, ymin, ymax} defining the sub-region. |
- Returns
- 2D point coordinates within the restricted bounding box.
◆ sample() [5/5]
| glm::vec2 hmap::InverseSampler2D::sample |
( |
const BBox2D & | restricted_bbox, |
|
|
float | u, |
|
|
float | u2 ) |
Samples a single point within a restricted bounding box with user-provided uniform random numbers.
- Parameters
-
| restricted_bbox | Bounding box {xmin, xmax, ymin, ymax} defining the sub-region. |
| u | Uniform random number in [0, 1) for row selection. |
| u2 | Uniform random number in [0, 1) for column selection. |
- Returns
- 2D point coordinates within the restricted bounding box.
◆ update_region() [1/2]
| void hmap::InverseSampler2D::update_region |
( |
const Array & | updated_array, |
|
|
const glm::ivec2 & | range_i, |
|
|
const glm::ivec2 & | range_j ) |
Updates the density in the sub-region [imin, imax] x [jmin, jmax] from another array.
- Parameters
-
| updated_array | Array containing updated density values. |
| range_i | Column index range {imin, imax} (inclusive). |
| range_j | Row index range {jmin, jmax} (inclusive). |
◆ update_region() [2/2]
| void hmap::InverseSampler2D::update_region |
( |
const std::function< float(int i, int j, float current)> & | updater, |
|
|
const glm::ivec2 & | range_i, |
|
|
const glm::ivec2 & | range_j ) |
Updates the density in the sub-region [imin, imax] x [jmin, jmax] using a modifier function.
- Parameters
-
| updater | Callback f(i, j, current_val) returning the new density value. |
| range_i | Column index range {imin, imax} (inclusive). |
| range_j | Row index range {jmin, jmax} (inclusive). |
◆ reset()
| void hmap::InverseSampler2D::reset |
( |
const Array & | density, |
|
|
std::uint32_t | seed = 0, |
|
|
const BBox2D & | bbox = BBox2D{} ) |
Reinitializes the sampler with a new density array.
- Parameters
-
| density | 2D density array. |
| seed | Random number generator seed. |
| bbox | Bounding box (xmin, xmax, ymin, ymax). |
◆ get_bbox()
| const BBox2D & hmap::InverseSampler2D::get_bbox |
( |
| ) |
const |
◆ get_density()
| const Array & hmap::InverseSampler2D::get_density |
( |
| ) |
const |
Gets the current density array.
◆ get_total_weight()
| float hmap::InverseSampler2D::get_total_weight |
( |
| ) |
const |
Gets the total integrated weight.
◆ set_bbox()
| void hmap::InverseSampler2D::set_bbox |
( |
const BBox2D & | bbox | ) |
|
◆ set_seed()
| void hmap::InverseSampler2D::set_seed |
( |
std::uint32_t | seed | ) |
|
The documentation for this class was generated from the following files: