src/albedo/maturity.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | |||
| 3 | #include "terraingen/albedo/maturity.h" | ||
| 4 | |||
| 5 | #include "util/checks.h" | ||
| 6 | |||
| 7 | #include <cmath> | ||
| 8 | #include <stdexcept> | ||
| 9 | |||
| 10 | namespace terraingen { | ||
| 11 | |||
| 12 | 190982 | double ReflectanceAtMaturity(double reflectance, double reference, double maturity, | |
| 13 | double originReflectance) { | ||
| 14 | 572943 | if (!(IsPositive(reference) && IsNonNegative(maturity) && std::isfinite(originReflectance))) { | |
| 15 | 3 | throw std::invalid_argument( | |
| 16 | 3 | "Reflectance at a maturity needs a positive reference and a non-negative maturity"); | |
| 17 | } | ||
| 18 | 190979 | const double origin = std::fmin(originReflectance, reflectance); | |
| 19 | 190979 | return origin + (reflectance - origin) * maturity / reference; | |
| 20 | } | ||
| 21 | |||
| 22 | } // namespace terraingen | ||
| 23 |