TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
4 / 4
100.0%
Branches:
-
-%
Functions:
2 / 2
100.0%

distribution/golombek_rapp.h
Line Branch Exec Source
1 /// @file
2 /// @brief Boulder sizes after Golombek and Rapp (1997), from the fraction of ground boulders cover.
3 #pragma once
4
5 #include "terraingen/distribution/size_frequency.h"
6
7 namespace terraingen {
8
9 /// Boulder densities whose cumulative fractional area is F(D) = k exp(-q D), with q = `qa` +
10 /// `qb` / k per metre and k the fraction of ground the boulders cover (`coverage`); N(>=D) =
11 /// (4 k q / pi) E2(q D) / D per m^2.
12 class GolombekRappSfd final : public SizeFrequencyDistribution {
13 public:
14 /// The distribution for coverage k.
15 /// @param coverage k, the fractional area covered by boulders, in (0, 1).
16 /// @param qa The constant part of q, per metre; finite and not negative.
17 /// @param qb The part of q that scales with 1 / k, per metre; finite and not negative.
18 /// @param range Diameters in metres where it is valid.
19 /// @throws std::invalid_argument for a coverage outside (0, 1), a negative or non-finite `qa`
20 /// or `qb`, a q that is not positive, or an invalid range.
21 explicit GolombekRappSfd(double coverage, double qa = 1.79, double qb = 0.152,
22 DiameterRange range = {});
23
24 /// k, the fractional area covered by boulders, in (0, 1).
25 1 double Coverage() const {
26 1 return coverage_;
27 }
28
29 /// q = qa + qb / k, the size scale of the exponential, per metre.
30 5 double Q() const {
31 5 return q_;
32 }
33
34 /// F(D) = k exp(-q D), the fractional area covered by boulders at least `diameter` metres
35 /// across.
36 double FractionalArea(double diameter) const;
37
38 protected:
39 double CumulativeAt(double diameter) const override;
40 double IncrementalAt(double diameter) const override;
41
42 private:
43 double coverage_;
44 double q_;
45 };
46
47 } // namespace terraingen
48