stretch factor in cylindrical equidistant and cylindrical equi-area models

This commit is contained in:
Zeno Rogue 2018-07-30 17:44:11 +02:00
parent c252f1f09c
commit e27cd9b654
6 changed files with 73 additions and 39 deletions

View File

@ -254,6 +254,7 @@ void initConfig() {
addsaverenum(stereo::mode, "stereo-mode");
addsaver(vid.euclid_to_sphere, "euclid to sphere projection", 1.5);
addsaver(vid.twopoint_param, "twopoint parameter", 1);
addsaver(vid.stretch, "stretch", 1);
addsaver(gp::on, "goldberg", false);
addsaver(gp::param.first, "goldberg-x", gp::param.first);

View File

@ -641,6 +641,10 @@ namespace conformal {
dialog::addSelItem(XLAT("parameter"), fts3(vid.twopoint_param), 'l');
}
if(among(pmodel, mdBandEquidistant, mdBandEquiarea)) {
dialog::addSelItem(XLAT("parameter"), fts3(vid.stretch), 'l');
}
dialog::addBreak(100);
dialog::addItem(XLAT("history mode"), 'a');
#if CAP_RUG
@ -685,6 +689,10 @@ namespace conformal {
#endif
else if(uni == 'l' && pmodel == mdHalfplane)
lower_halfplane = !lower_halfplane;
else if(uni == 'l' && among(pmodel, mdBandEquiarea, mdBandEquidistant))
dialog::editNumber(vid.stretch, 0, 10, .1, 1, XLAT("parameter"),
"Vertical stretch factor."
);
else if(uni == 'a')
pushScreen(history_menu);
else if(uni == 'l' && pmodel == mdHemisphere && euclid) {

View File

@ -749,6 +749,11 @@ namespace dialog {
addSelItem("game range bonus", its(gamerange_bonus), 'O');
}
if(ne.editwhat == &vid.stretch && sphere && pmodel == mdBandEquiarea) {
addBoolItem("Gall-Peters", vid.stretch == 2, 'o');
add_action([] { vid.stretch = 2; });
}
if(ne.editwhat == &vid.linewidth)
addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'o');

View File

@ -806,7 +806,7 @@ extern reaction_t help_delegate;
struct videopar {
ld scale, alpha, sspeed, mspeed, yshift, camera_angle;
ld ballangle, ballproj, euclid_to_sphere, twopoint_param;
ld ballangle, ballproj, euclid_to_sphere, twopoint_param, stretch;
int mobilecompasssize;
int aurastr, aurasmoothen;

View File

@ -276,7 +276,9 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
else if(H[2] < 0 && x <= 0) x = -M_PI - x;
}
hypot_zlev(zlev_used, y, zlev, yf, zf);
if(pmodel == mdTwoPoint) {
switch(pmodel) {
case mdTwoPoint: {
auto p = vid.twopoint_param;
ld dleft = hypot_auto(x-p, y);
ld dright = hypot_auto(x+p, y);
@ -295,8 +297,10 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
}
x = (dright*dright-dleft*dleft) / 4 / p;
y = (y>0?1:-1) * sqrt(dleft * dleft - (x-p)*(x-p) + 1e-9);
break;
}
else if(pmodel == mdBand) switch(cgclass) {
case mdBand: {
switch(cgclass) {
case gcSphere:
y = atanh(sin(y));
x *= 2; y *= 2;
@ -310,10 +314,24 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
y *= 2; x *= 2;
break;
}
else if(pmodel == mdBandEquiarea)
y = sin_auto(y);
else if(pmodel == mdSinusoidal)
break;
}
case mdBandEquiarea: {
y = sin_auto(y) * vid.stretch;
break;
}
case mdSinusoidal: {
x *= cos_auto(y);
break;
}
case mdBandEquidistant: {
y *= vid.stretch;
break;
}
default: {
printf("unknown model\n");
}
}
ret = hpxyz(x / M_PI, y * yf / M_PI, 0);
if(zlev_used && stereo::active())
apply_depth(ret, y * zf / M_PI);

View File

@ -459,10 +459,12 @@ void fixMercator(bool tinf) {
ld cmin = -vid.xcenter, cmax = vid.xres - vid.xcenter, dmin = -vid.ycenter, dmax = vid.yres - vid.ycenter;
if(mercator_coord)
swap(cmin, dmin), swap(cmax, dmax);
if(pmodel == mdSinusoidal || pmodel == mdBandEquidistant)
if(pmodel == mdSinusoidal)
dmin = -vid.radius / 2, dmax = vid.radius / 2;
if(pmodel == mdBandEquidistant)
dmin = -vid.stretch * vid.radius / 2, dmax = vid.stretch * vid.radius / 2;
if(pmodel == mdBandEquiarea)
dmin = -vid.radius / M_PI, dmax = vid.radius / M_PI;
dmin = -vid.stretch * vid.radius / M_PI, dmax = vid.stretch * vid.radius / M_PI;
for(int i = 0; i<isize(glcoords); i++) {
while(glcoords[0][mercator_coord] < hperiod) glcoords[0][mercator_coord] += mercator_period;