From 876ece1ff6a281f3cdf2040b73c53557a29d3693 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 14 Aug 2019 19:08:16 +0200 Subject: [PATCH] renamed fixMercator to cyl::adjust, and its variables accordingly --- drawing.cpp | 76 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 867dbbc6..c602f9a8 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -680,11 +680,12 @@ EX void set_width(ld w) { glhr::set_linewidth(w); } -// -radius to +3radius +// this part makes cylindrical projections on the sphere work -int mercator_coord; -int mercator_loop_min = 0, mercator_loop_max = 0; -ld mercator_period; +namespace cyl { + +int loop_min = 0, loop_max = 0; +ld period; auto pzero(ld t) { if(abs(t) < 1e-6) return 2 * current_display->radius; @@ -713,9 +714,9 @@ ld period_at(ld y) { } } -void fixMercator(bool tinf) { +void adjust(bool tinf) { - mercator_period = period_at(0); + period = period_at(0); if(!models::model_straight) for(auto& g: glcoords) @@ -723,18 +724,14 @@ void fixMercator(bool tinf) { if(mdPseudocylindrical()) for(int i = 0; ixcenter), dist(vid.yres, current_display->ycenter)); ld cmin = -chypot/2, cmax = chypot/2, dmin = -chypot, dmax = chypot; - if(mercator_coord) - swap(cmin, dmin), swap(cmax, dmax); if(pmodel == mdSinusoidal) dmin = -vid.stretch * current_display->radius / 2, dmax = vid.stretch * current_display->radius / 2; if(pmodel == mdBandEquidistant) @@ -742,35 +739,35 @@ void fixMercator(bool tinf) { if(pmodel == mdBandEquiarea) dmin = -vid.stretch * current_display->radius / M_PI, dmax = vid.stretch * current_display->radius / M_PI; - glcoords[0][mercator_coord] -= round_nearest(glcoords[0][mercator_coord], mercator_period); + glcoords[0][0] -= round_nearest(glcoords[0][0], period); - ld first = glcoords[0][mercator_coord]; + ld first = glcoords[0][0]; ld next = first; ld mincoord = first, maxcoord = first; for(int i = 0; i(mincoord, glcoords[i][mercator_coord]); - maxcoord = max(maxcoord, glcoords[i][mercator_coord]); + glcoords[i][0] -= round_nearest(glcoords[i][0]-next, period); + next = glcoords[i][0]; + mincoord = min(mincoord, glcoords[i][0]); + maxcoord = max(maxcoord, glcoords[i][0]); } if(abs(mincoord) > 50000 || abs(maxcoord) > 50000 || std::isnan(mincoord) || std::isnan(maxcoord)) { - mercator_loop_max--; + loop_max--; return; } - ld last = first - round_nearest(first-next, mercator_period); + ld last = first - round_nearest(first-next, period); if(abs(first - last) < 1e-6) { - while(mincoord > cmin && mercator_loop_min > -100) - mercator_loop_min--, mincoord -= mercator_period; - while(maxcoord < cmax && mercator_loop_max < +100) - mercator_loop_max++, maxcoord += mercator_period; + while(mincoord > cmin && loop_min > -100) + loop_min--, mincoord -= period; + while(maxcoord < cmax && loop_max < +100) + loop_max++, maxcoord += period; if(mdPseudocylindrical()) for(int i = 0; i