1+ /* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2+ Public License. The full license is in the file LICENSE, distributed with
3+ this software. */
4+
5+ /* *
6+ * @file random.hpp
7+ * @author Otto Link (otto.link.bv@gmail.com)
8+ * @copyright Copyright (c) 2023
9+ */
10+ #pragma once
11+
12+ #include " highmap/array.hpp"
13+
14+ namespace hmap
15+ {
16+
17+ /* *
18+ * @brief Return an array filled with white noise.
19+ *
20+ * @param shape Array shape.
21+ * @param a Lower bound of random distribution.
22+ * @param b Upper bound of random distribution.
23+ * @param seed Random number seed.
24+ * @return Array White noise.
25+ *
26+ * **Example**
27+ * @include ex_white.cpp
28+ *
29+ * **Result**
30+ * @image html ex_white.png
31+ *
32+ * @see {@link white_sparse}
33+ */
34+ Array white (glm::ivec2 shape, float a, float b, std::uint32_t seed);
35+
36+ /* *
37+ * @brief Return an array filled `1` with a probability based on a density map.
38+ *
39+ * @param density_map Density map.
40+ * @param seed Random number seed.
41+ * @return Array New array.
42+ *
43+ * **Example**
44+ * @include ex_white_density_map.cpp
45+ *
46+ * **Result**
47+ * @image html ex_white_density_map.png
48+ */
49+ Array white_density_map (const Array &density_map, std::uint32_t seed);
50+
51+ /* *
52+ * @brief Return an array sparsely filled with white noise.
53+ *
54+ * @param shape Array shape.
55+ * @param a Lower bound of random distribution.
56+ * @param b Upper bound of random distribution.
57+ * @param density Array filling density, in [0, 1]. If set to 1, the function
58+ * is equivalent to {@link white}.
59+ * @param seed Random number seed.
60+ * @return Array Sparse white noise.
61+ *
62+ * **Example**
63+ * @include ex_white_sparse.cpp
64+ *
65+ * **Result**
66+ * @image html ex_white_sparse.png
67+ *
68+ * @see {@link white}
69+ */
70+ Array white_sparse (glm::ivec2 shape,
71+ float a,
72+ float b,
73+ float density,
74+ std::uint32_t seed);
75+
76+ /* *
77+ * @brief Return an array sparsely filled with random 0 and 1.
78+ *
79+ * @param shape Array shape.
80+ * @param density Array filling density, in [0, 1]. If set to 1, the function
81+ * is equivalent to {@link white}.
82+ * @param seed Random number seed.
83+ * @return Array Sparse white noise.
84+ */
85+ Array white_sparse_binary (glm::ivec2 shape, float density, std::uint32_t seed);
86+
87+ } // namespace hmap
0 commit comments