include/terraingen/albedo/blast_zones.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | |||
| 3 | /// @file | ||
| 4 | /// @brief Blast zones: the regolith a lander's descent engine scoured, brighter than around it. | ||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "terraingen/albedo/albedo.h" | ||
| 8 | #include "terraingen/geometry/surface.h" | ||
| 9 | |||
| 10 | #include <cstdint> | ||
| 11 | #include <vector> | ||
| 12 | |||
| 13 | namespace terraingen { | ||
| 14 | |||
| 15 | /// The blast zone around one lander (Clegg et al. 2014; Clegg-Watkins et al. 2016): an elliptical | ||
| 16 | /// zone brighter by `change` on average, a fainter halo and an optional dark core, relative to the | ||
| 17 | /// undisturbed ground at 30 degrees phase. | ||
| 18 | 5 | struct BlastZone { | |
| 19 | double x = 0.0; ///< Surface x of the lander. | ||
| 20 | double y = 0.0; ///< Surface y of the lander. | ||
| 21 | double area = 28785.0; ///< Area of the zone (m^2), the Apollo mean; positive. | ||
| 22 | double elongation = 1.14; ///< Long over short axis; Apollo 200 / 175, Chang'e-3 1.74. | ||
| 23 | double headingDegrees = 90.0; ///< Long axis, degrees counter-clockwise from east. | ||
| 24 | double change = 0.109; ///< Mean reflectance change over the zone; above -1. | ||
| 25 | double haloChange = 0.04; ///< Change of the halo beyond the zone (Chang'e-3). | ||
| 26 | double haloReach = 1.9; ///< Halo's reach over the zone's (Chang'e-3); at least 1. | ||
| 27 | double coreRadius = 0.0; ///< Radius of the dark core (m); 0 for none. | ||
| 28 | double coreChange = -0.2; ///< Change of the dark core; above -1. | ||
| 29 | double raggedness = 0.15; ///< Share of the radius the edge's lobes pull in, [0, 1). | ||
| 30 | std::uint32_t seed = 0; ///< Varies the edge's lobes. | ||
| 31 | |||
| 32 | bool operator==(const BlastZone& other) const { | ||
| 33 | return x == other.x && y == other.y && area == other.area && | ||
| 34 | elongation == other.elongation && headingDegrees == other.headingDegrees && | ||
| 35 | change == other.change && haloChange == other.haloChange && | ||
| 36 | haloReach == other.haloReach && coreRadius == other.coreRadius && | ||
| 37 | coreChange == other.coreChange && raggedness == other.raggedness && | ||
| 38 | seed == other.seed; | ||
| 39 | } | ||
| 40 | bool operator!=(const BlastZone& other) const { | ||
| 41 | return !(*this == other); | ||
| 42 | } | ||
| 43 | }; | ||
| 44 | |||
| 45 | /// Checks a blast zone. | ||
| 46 | /// @throws std::invalid_argument naming the first field out of its range. | ||
| 47 | void ValidateBlastZone(const BlastZone& zone); | ||
| 48 | |||
| 49 | /// The share of a zone's peak change it averages over its area, by the radial profile: full out | ||
| 50 | /// to 0.3 of the radius, then fading to 0 at the edge. | ||
| 51 | double BlastZoneMeanShare(); | ||
| 52 | |||
| 53 | /// Blast zones around landers, changing the albedo by the relative reflectance they give; the | ||
| 54 | /// same in any grid, tile or point. | ||
| 55 | 7 | class BlastZoneAlbedo final : public AlbedoLayer { | |
| 56 | public: | ||
| 57 | /// @throws std::invalid_argument for a zone invalid as `ValidateBlastZone`. | ||
| 58 | explicit BlastZoneAlbedo(std::vector<BlastZone> zones); | ||
| 59 | |||
| 60 | /// Changes the albedo at one point on the context's surface by the zones over it; NaN stays | ||
| 61 | /// NaN. | ||
| 62 | void ApplyAt(AlbedoSample& value, std::size_t bands, double x, double y, | ||
| 63 | const LayerContext& context) const override; | ||
| 64 | |||
| 65 | /// The relative reflectance change `zone` gives (`x`, `y`) on `surface`. | ||
| 66 | static double Change(const BlastZone& zone, double x, double y, const Surface& surface = {}); | ||
| 67 | |||
| 68 | /// How far (m) from its lander `zone` changes the ground. | ||
| 69 | static double Reach(const BlastZone& zone); | ||
| 70 | |||
| 71 | private: | ||
| 72 | std::vector<BlastZone> m_zones; | ||
| 73 | }; | ||
| 74 | |||
| 75 | } // namespace terraingen | ||
| 76 |