mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-30 15:27:02 +00:00
stretch factor in cylindrical equidistant and cylindrical equi-area models
This commit is contained in:
parent
c252f1f09c
commit
e27cd9b654
@ -254,6 +254,7 @@ void initConfig() {
|
|||||||
addsaverenum(stereo::mode, "stereo-mode");
|
addsaverenum(stereo::mode, "stereo-mode");
|
||||||
addsaver(vid.euclid_to_sphere, "euclid to sphere projection", 1.5);
|
addsaver(vid.euclid_to_sphere, "euclid to sphere projection", 1.5);
|
||||||
addsaver(vid.twopoint_param, "twopoint parameter", 1);
|
addsaver(vid.twopoint_param, "twopoint parameter", 1);
|
||||||
|
addsaver(vid.stretch, "stretch", 1);
|
||||||
|
|
||||||
addsaver(gp::on, "goldberg", false);
|
addsaver(gp::on, "goldberg", false);
|
||||||
addsaver(gp::param.first, "goldberg-x", gp::param.first);
|
addsaver(gp::param.first, "goldberg-x", gp::param.first);
|
||||||
|
@ -640,6 +640,10 @@ namespace conformal {
|
|||||||
if(pmodel == mdTwoPoint) {
|
if(pmodel == mdTwoPoint) {
|
||||||
dialog::addSelItem(XLAT("parameter"), fts3(vid.twopoint_param), 'l');
|
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::addBreak(100);
|
||||||
dialog::addItem(XLAT("history mode"), 'a');
|
dialog::addItem(XLAT("history mode"), 'a');
|
||||||
@ -685,6 +689,10 @@ namespace conformal {
|
|||||||
#endif
|
#endif
|
||||||
else if(uni == 'l' && pmodel == mdHalfplane)
|
else if(uni == 'l' && pmodel == mdHalfplane)
|
||||||
lower_halfplane = !lower_halfplane;
|
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')
|
else if(uni == 'a')
|
||||||
pushScreen(history_menu);
|
pushScreen(history_menu);
|
||||||
else if(uni == 'l' && pmodel == mdHemisphere && euclid) {
|
else if(uni == 'l' && pmodel == mdHemisphere && euclid) {
|
||||||
|
@ -748,6 +748,11 @@ namespace dialog {
|
|||||||
addSelItem("generation range bonus", its(genrange_bonus), 'o');
|
addSelItem("generation range bonus", its(genrange_bonus), 'o');
|
||||||
addSelItem("game range bonus", its(gamerange_bonus), 'O');
|
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)
|
if(ne.editwhat == &vid.linewidth)
|
||||||
addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'o');
|
addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'o');
|
||||||
|
2
hyper.h
2
hyper.h
@ -806,7 +806,7 @@ extern reaction_t help_delegate;
|
|||||||
|
|
||||||
struct videopar {
|
struct videopar {
|
||||||
ld scale, alpha, sspeed, mspeed, yshift, camera_angle;
|
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 mobilecompasssize;
|
||||||
int aurastr, aurasmoothen;
|
int aurastr, aurasmoothen;
|
||||||
|
|
||||||
|
88
hypgraph.cpp
88
hypgraph.cpp
@ -276,44 +276,62 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
|
|||||||
else if(H[2] < 0 && x <= 0) x = -M_PI - x;
|
else if(H[2] < 0 && x <= 0) x = -M_PI - x;
|
||||||
}
|
}
|
||||||
hypot_zlev(zlev_used, y, zlev, yf, zf);
|
hypot_zlev(zlev_used, y, zlev, yf, zf);
|
||||||
if(pmodel == mdTwoPoint) {
|
|
||||||
auto p = vid.twopoint_param;
|
switch(pmodel) {
|
||||||
ld dleft = hypot_auto(x-p, y);
|
case mdTwoPoint: {
|
||||||
ld dright = hypot_auto(x+p, y);
|
auto p = vid.twopoint_param;
|
||||||
if(sphere) {
|
ld dleft = hypot_auto(x-p, y);
|
||||||
int tss = twopoint_sphere_flips;
|
ld dright = hypot_auto(x+p, y);
|
||||||
if(tss&1) { tss--;
|
if(sphere) {
|
||||||
dleft = 2*M_PI - 2*p - dleft;
|
int tss = twopoint_sphere_flips;
|
||||||
dright = 2*M_PI - 2*p - dright;
|
if(tss&1) { tss--;
|
||||||
swap(dleft, dright);
|
dleft = 2*M_PI - 2*p - dleft;
|
||||||
y = -y;
|
dright = 2*M_PI - 2*p - dright;
|
||||||
}
|
swap(dleft, dright);
|
||||||
while(tss) { tss -= 2;
|
y = -y;
|
||||||
dleft = 2*M_PI - 4*p + dleft;
|
}
|
||||||
dright = 2*M_PI - 4*p + dright;
|
while(tss) { tss -= 2;
|
||||||
|
dleft = 2*M_PI - 4*p + dleft;
|
||||||
|
dright = 2*M_PI - 4*p + dright;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
x = (dright*dright-dleft*dleft) / 4 / p;
|
||||||
|
y = (y>0?1:-1) * sqrt(dleft * dleft - (x-p)*(x-p) + 1e-9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case mdBand: {
|
||||||
|
switch(cgclass) {
|
||||||
|
case gcSphere:
|
||||||
|
y = atanh(sin(y));
|
||||||
|
x *= 2; y *= 2;
|
||||||
|
break;
|
||||||
|
case gcHyperbolic:
|
||||||
|
y = 2 * atan(tanh(y/2));
|
||||||
|
x *= 2; y *= 2;
|
||||||
|
break;
|
||||||
|
case gcEuclid:
|
||||||
|
// y = y;
|
||||||
|
y *= 2; x *= 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
x = (dright*dright-dleft*dleft) / 4 / p;
|
|
||||||
y = (y>0?1:-1) * sqrt(dleft * dleft - (x-p)*(x-p) + 1e-9);
|
|
||||||
}
|
}
|
||||||
else if(pmodel == mdBand) switch(cgclass) {
|
|
||||||
case gcSphere:
|
|
||||||
y = atanh(sin(y));
|
|
||||||
x *= 2; y *= 2;
|
|
||||||
break;
|
|
||||||
case gcHyperbolic:
|
|
||||||
y = 2 * atan(tanh(y/2));
|
|
||||||
x *= 2; y *= 2;
|
|
||||||
break;
|
|
||||||
case gcEuclid:
|
|
||||||
// y = y;
|
|
||||||
y *= 2; x *= 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if(pmodel == mdBandEquiarea)
|
|
||||||
y = sin_auto(y);
|
|
||||||
else if(pmodel == mdSinusoidal)
|
|
||||||
x *= cos_auto(y);
|
|
||||||
ret = hpxyz(x / M_PI, y * yf / M_PI, 0);
|
ret = hpxyz(x / M_PI, y * yf / M_PI, 0);
|
||||||
if(zlev_used && stereo::active())
|
if(zlev_used && stereo::active())
|
||||||
apply_depth(ret, y * zf / M_PI);
|
apply_depth(ret, y * zf / M_PI);
|
||||||
|
@ -451,7 +451,7 @@ void fixMercator(bool tinf) {
|
|||||||
|
|
||||||
if(pmodel == mdSinusoidal)
|
if(pmodel == mdSinusoidal)
|
||||||
for(int i = 0; i<isize(glcoords); i++)
|
for(int i = 0; i<isize(glcoords); i++)
|
||||||
glcoords[i][mercator_coord] /= cos(glcoords[i][1] / vid.radius * M_PI);
|
glcoords[i][mercator_coord] /= cos(glcoords[i][1] / vid.radius * M_PI);
|
||||||
|
|
||||||
ld hperiod = mercator_period / 2;
|
ld hperiod = mercator_period / 2;
|
||||||
|
|
||||||
@ -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;
|
ld cmin = -vid.xcenter, cmax = vid.xres - vid.xcenter, dmin = -vid.ycenter, dmax = vid.yres - vid.ycenter;
|
||||||
if(mercator_coord)
|
if(mercator_coord)
|
||||||
swap(cmin, dmin), swap(cmax, dmax);
|
swap(cmin, dmin), swap(cmax, dmax);
|
||||||
if(pmodel == mdSinusoidal || pmodel == mdBandEquidistant)
|
if(pmodel == mdSinusoidal)
|
||||||
dmin = -vid.radius / 2, dmax = vid.radius / 2;
|
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)
|
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++) {
|
for(int i = 0; i<isize(glcoords); i++) {
|
||||||
while(glcoords[0][mercator_coord] < hperiod) glcoords[0][mercator_coord] += mercator_period;
|
while(glcoords[0][mercator_coord] < hperiod) glcoords[0][mercator_coord] += mercator_period;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user