albedo/maturity.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "terraingen/albedo/maturity.h" | ||
| 2 | |||
| 3 | #include "terraingen/util/checks.h" | ||
| 4 | |||
| 5 | #include <cmath> | ||
| 6 | #include <stdexcept> | ||
| 7 | |||
| 8 | namespace terraingen { | ||
| 9 | |||
| 10 | 6 | double OpticalMaturity(double r750, double r950, const OpticalMaturityOrigin& origin) { | |
| 11 | 6 | if (!(IsPositive(r750) && std::isfinite(r950))) { | |
| 12 | 2 | throw std::invalid_argument("Optical maturity needs a positive 750 nm reflectance"); | |
| 13 | } | ||
| 14 | 4 | return std::hypot(r750 - origin.reflectance, r950 / r750 - origin.ratio); | |
| 15 | } | ||
| 16 | |||
| 17 | 1025803 | double ReflectanceAtMaturity(double reflectance, double reference, double maturity, | |
| 18 | double originReflectance) { | ||
| 19 | 1025803 | if (!(IsPositive(reference) && IsNonNegative(maturity) && std::isfinite(originReflectance))) { | |
| 20 | throw std::invalid_argument( | ||
| 21 | 3 | "Reflectance at a maturity needs a positive reference and a non-negative maturity"); | |
| 22 | } | ||
| 23 | 1025800 | const double origin = std::fmin(originReflectance, reflectance); | |
| 24 | 1025800 | return origin + (reflectance - origin) * maturity / reference; | |
| 25 | } | ||
| 26 | |||
| 27 | } // namespace terraingen | ||
| 28 |