layers/craters/rays.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /// @file | ||
| 2 | /// @brief The directions of a crater's rays, shared by its secondaries and its bright streaks. | ||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include "terraingen/layers/craters/crater.h" | ||
| 6 | #include "terraingen/random/value_distribution.h" | ||
| 7 | |||
| 8 | #include <cstdint> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | namespace terraingen { | ||
| 12 | |||
| 13 | /// How many rays a crater has and how wide they are, after Elliott et al. (2018), drawn from the | ||
| 14 | /// crater's ID and `seed`; layers given the same layout see the same rays. | ||
| 15 | struct RayLayout { | ||
| 16 | 2 | std::uint32_t seed = 0; ///< Seed of the directions. | |
| 17 | /// Rays per crater, 0 to 64. | ||
| 18 | 2 | ValueDistribution count{ValueDistribution::Kind::Normal, 10.7, 3.1, 6.0, 20.0}; | |
| 19 | /// Angular width 2 radii from the centre, in (0, 180) degrees. | ||
| 20 | 2 | ValueDistribution widthDegrees{ValueDistribution::Kind::Normal, 22.0, 8.3, 5.4, 38.6}; | |
| 21 | |||
| 22 | 2 | bool operator==(const RayLayout&) const = default; | |
| 23 | }; | ||
| 24 | |||
| 25 | /// Checks a ray layout. | ||
| 26 | /// @throws std::invalid_argument for invalid distributions, a count that can be below 0 or above | ||
| 27 | /// 64, or widths outside (0, 180) degrees. | ||
| 28 | void ValidateRayLayout(const RayLayout& layout); | ||
| 29 | |||
| 30 | /// One ray of a crater. | ||
| 31 | struct RayDirection { | ||
| 32 | double azimuth = 0.0; ///< Radians counter-clockwise from east. | ||
| 33 | double sinHalfWidth = 0.0; ///< Sine of half its angular width 2 radii from the centre. | ||
| 34 | std::uint32_t key = 0; ///< Varies what lies along the ray. | ||
| 35 | }; | ||
| 36 | |||
| 37 | /// The rays of `crater` under `layout`, at uniform random azimuths. | ||
| 38 | std::vector<RayDirection> RayDirections(const Crater& crater, const RayLayout& layout); | ||
| 39 | |||
| 40 | } // namespace terraingen | ||
| 41 |