layers/craters/degradation/degradation_model.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "terraingen/layers/craters/degradation/degradation_model.h" | ||
| 2 | |||
| 3 | #include "terraingen/util/checks.h" | ||
| 4 | |||
| 5 | #include <cmath> | ||
| 6 | #include <stdexcept> | ||
| 7 | #include <utility> | ||
| 8 | |||
| 9 | namespace terraingen { | ||
| 10 | |||
| 11 | 2 | CraterState DegradationModel::WornState(const Crater& crater, double rate) const { | |
| 12 | 2 | Crater older = crater; | |
| 13 | 2 | older.ageGyr *= rate; | |
| 14 | 4 | return State(older); | |
| 15 | } | ||
| 16 | |||
| 17 | 878 | NoDegradation::NoDegradation(FreshMorphometry fresh, std::optional<double> depthRatio) | |
| 18 | 878 | : fresh_(std::move(fresh)), depthRatio_(depthRatio) { | |
| 19 | 878 | if (!fresh_) { | |
| 20 | 1 | throw std::invalid_argument("No degradation needs the fresh crater morphometry"); | |
| 21 | } | ||
| 22 | 877 | if (depthRatio_) { | |
| 23 | 53 | RequirePositive(*depthRatio_, "Depth/diameter ratio"); | |
| 24 | } | ||
| 25 | 881 | } | |
| 26 | |||
| 27 | 55732 | CraterState NoDegradation::State(const Crater& crater) const { | |
| 28 | 55732 | CraterMorphometry fresh = fresh_(crater.diameter); | |
| 29 | 55731 | if (depthRatio_) { | |
| 30 | 3437 | fresh.depthRatio = *depthRatio_; | |
| 31 | } | ||
| 32 | 55731 | return {fresh, fresh}; | |
| 33 | } | ||
| 34 | |||
| 35 | } // namespace terraingen | ||
| 36 |