Rise
The Vieneo Province
Loading...
Searching...
No Matches
Tests/CloudLightVisibilityTests.cpp

Source at documentation-generation time. See Test catalog for fixture associations.

1#include "../Viewscreen/CloudVolume.h"
2#include <cstdlib>
3#include <iostream>
4
5static unsigned checks=0;
6static void Check(bool value,const char* message)
7{
8 ++checks;
9 if(!value) { std::cerr<<"FAIL: "<<message<<'\n'; std::exit(1); }
10}
11
12int main()
13{
14 using namespace CloudVolume;
15 // Freedom runway 36 descent, 2026-10-02 03:36:08Z: 6.6885 km MSL.
16 // Nearby server observations put the base at 6.124--6.208 km MSL.
17 // This reproduces the sightline, not an exact historical density field:
18 // the client's convection map and advected noise offset were not recorded.
19 const Point eye{-789.93f,2758.942f,-666.9764f};
20 const double radians=std::acos(-1.0)/180;
21 const double latitude=12.861*radians,longitude=15.977*radians;
22 const Point airportRadial{float(-std::cos(latitude)*std::sin(longitude)),
23 float(std::cos(latitude)*std::cos(longitude)),float(-std::sin(latitude))};
24 for(float base : {6.124f,6.208f})
25 {
26 Parameters params; params.base=base; params.activity=.4f;
27 const Point lamp=Scale(airportRadial,params.radius+5.703f); // 10 m above airport
28 Check(Length(Add(lamp,Scale(eye,-1)))>11.f,"reconstruct an airport lamp over 11 km away");
29 const float obscured=Transmittance(eye,lamp,params);
30 Check(obscured<.001f,"ground lamp is hidden through the reported in-cloud sightline");
31 const auto below=Scale(eye,(params.radius+5.75f)/Length(eye));
32 Check(Transmittance(below,lamp,params)>.99f,"clear sightline below the deck preserves ground lights");
33 const float nearby=Transmittance(eye,Add(eye,{.005f,0,0}),params);
34 Check(nearby>.5f,"nearby lamp remains visible inside cloud; no blanket altitude switch");
35 const auto above=Scale(eye,(params.radius+25.f)/Length(eye));
36 Check(Transmittance(above,lamp,params)<.001f,"clouds block the lamp even with both endpoints in clear air");
37 // The sprite check is position-based, independent of travel direction.
38 float descent[161]{};
39 for(int i=160;i>=0;--i)
40 {
41 const auto p=Scale(eye,(params.radius+5.75f+i*.01f)/Length(eye));
42 descent[i]=Transmittance(p,lamp,params);
43 }
44 for(int i=0;i<=160;++i)
45 {
46 const auto p=Scale(eye,(params.radius+5.75f+i*.01f)/Length(eye));
47 Check(Transmittance(p,lamp,params)==descent[i],"ascending and descending give identical light visibility");
48 }
49 std::cout<<"Base "<<base<<" km MSL: airport transmission "<<obscured
50 <<", nearby lamp "<<nearby<<'\n';
51 }
52 std::cout<<"PASS: "<<checks<<" cloud light visibility checks.\n";
53}
Point Scale(Point p, float s)
Definition CloudVolume.h:93
Point Add(Point a, Point b)
Definition CloudVolume.h:95
float Transmittance(Point from, Point to, const Parameters &params, uint32_t seed=DefaultSeed)
float Length(Point p)
Definition CloudVolume.h:94