./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
10 / 10
100.0%
Branches:
9 / 20
45.0%
Functions:
2 / 2, 2 excl
100.0%

include/terraingen/layers/craters/degradation/state.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 /// @file
4 /// @brief A crater's shape measures and degradation state.
5 #pragma once
6
7 #include <functional>
8
9 namespace terraingen {
10
11 /// The depth over diameter at which Fassett et al. (2022, section 4) take a crater to be no longer
12 /// recognized, from the left tail of the d/D distributions of Mahanti et al. (2018).
13 inline constexpr double kVisibilityDepthRatio = 0.04;
14
15 /// A crater's shape measures relative to its diameter.
16 struct CraterMorphometry {
17 double depthRatio = 0.0; ///< Rim-to-floor depth / diameter.
18 double rimHeightRatio = 0.0; ///< Rim height above the pre-impact surface / diameter.
19
20 /// Memberwise equality.
21 192 bool operator==(const CraterMorphometry& other) const {
22
2/8
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
192 return depthRatio == other.depthRatio && rimHeightRatio == other.rimHeightRatio;
23 }
24 bool operator!=(const CraterMorphometry& other) const {
25 return !(*this == other);
26 }
27 };
28
29 /// A crater's degradation state: its morphometry when fresh and now.
30 struct CraterState {
31 CraterMorphometry fresh; ///< When fresh; some profiles place a degraded rim from it.
32 CraterMorphometry current; ///< Now; profiles shape the crater to it.
33 /// Diffusion age over diameter squared, kappa t / D^2, for profiles that diffuse the fresh
34 /// shape (`DiffusedProfile`); 0 for none.
35 double diffusion = 0.0;
36
37 /// How fresh the crater looks: its depth now over its depth when fresh; 1 for a fresh crater
38 /// (or one with no fresh depth), falling as it degrades.
39 52589 double Freshness() const {
40
4/6
<unknown function 21>:
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
<unknown function 39>:
✓ Branch 0 taken 34360 times.
✓ Branch 1 taken 1 time.
terraingen::CraterState::Freshness() const:
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
52589 return fresh.depthRatio > 0.0 ? current.depthRatio / fresh.depthRatio : 1.0;
41 }
42
43 /// Memberwise equality.
44 91 bool operator==(const CraterState& other) const {
45
3/6
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 91 times.
273 return fresh == other.fresh && current == other.current && diffusion == other.diffusion;
46 }
47 bool operator!=(const CraterState& other) const {
48 return !(*this == other);
49 }
50 };
51
52 /// The morphometry of a fresh crater of a diameter (m) on some body, such as
53 /// `LunarFreshCraterMorphometry`; must be thread-safe.
54 using FreshMorphometry = std::function<CraterMorphometry(double diameter)>;
55
56 } // namespace terraingen
57