./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
2 / 3
66.7%
Branches:
-
-%
Functions:
1 / 1, 1 excl
100.0%

include/terraingen/layers/craters/ages/freshness_ages.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief `FreshnessAges`, crater ages from a distribution of freshness.
5 #pragma once
6
7 #include "terraingen/layers/craters/ages/age_model.h"
8 #include "terraingen/random/value_distribution.h"
9
10 namespace terraingen {
11
12 /// Ages from a freshness f in [0, 1] drawn per crater: age = (1 - f) * lifetime, with one lifetime
13 /// for every diameter, so `RemainingLifetime` gives back f.
14 ✗ class FreshnessAges final : public CraterAgeModel {
15 public:
16 /// @param freshness The distribution f is drawn from; its clamp is narrowed to [0, 1].
17 /// @param lifetimeGyr The lifetime of every crater, in Gyr.
18 /// @throws std::invalid_argument unless `lifetimeGyr` is positive and finite and `freshness`,
19 /// once clamped to [0, 1], is valid (`ValidateValueDistribution`).
20 FreshnessAges(ValueDistribution freshness, double lifetimeGyr);
21
22 /// The distribution freshness is drawn from, clamped to [0, 1].
23 2 const ValueDistribution& Freshness() const {
24 2 return m_freshness;
25 }
26
27 /// Draws a freshness in [0, 1] from two draws of `random`.
28 double SampleFreshness(RandomStream& random) const;
29
30 protected:
31 double LifetimeAt(double diameter) const override;
32 double SampleAgeAt(RandomStream& random, double diameter, double lifetimeGyr) const override;
33
34 private:
35 ValueDistribution m_freshness;
36 double m_lifetimeGyr;
37 };
38
39 } // namespace terraingen
40