./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
6 / 6
100.0%
Branches:
5 / 7
71.4%
Functions:
1 / 1
100.0%

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
4/6
✓ Branch 0 taken 190982 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190981 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190979 times.
✓ Branch 5 taken 1 time.
572943 if (!(IsPositive(reference) && IsNonNegative(maturity) && std::isfinite(originReflectance))) {
15 3 throw std::invalid_argument(
16
1/1
✓ Branch 2 taken 3 times.
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