1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-11 18:00:34 +00:00

models:: Collignon projection

This commit is contained in:
Zeno Rogue 2019-08-14 18:59:21 +02:00
parent 2c073c1ec1
commit df9c01f276
4 changed files with 37 additions and 21 deletions

View File

@ -439,6 +439,8 @@ EX void initConfig() {
addsaver(vid.twopoint_param, "twopoint parameter", 1); addsaver(vid.twopoint_param, "twopoint parameter", 1);
addsaver(vid.stretch, "stretch", 1); addsaver(vid.stretch, "stretch", 1);
addsaver(vid.binary_width, "binary-tiling-width", 1); addsaver(vid.binary_width, "binary-tiling-width", 1);
addsaver(vid.collignon_parameter, "collignon-parameter", 1);
addsaver(vid.collignon_reflected, "collignon-reflect", false);
addsaver(vid.creature_scale, "3d-creaturescale", 1); addsaver(vid.creature_scale, "3d-creaturescale", 1);
addsaver(vid.height_width, "3d-heightwidth", 1.5); addsaver(vid.height_width, "3d-heightwidth", 1.5);
@ -2382,6 +2384,7 @@ EX unordered_map<string, ld&> params = {
{"fade", shot::fade}, {"fade", shot::fade},
{"mgrid", vid.multiplier_grid}, {"mgrid", vid.multiplier_grid},
{"mring", vid.multiplier_ring}, {"mring", vid.multiplier_ring},
{"collignon", vid.collignon_parameter},
#endif #endif
}; };

View File

@ -686,6 +686,11 @@ int mercator_coord;
int mercator_loop_min = 0, mercator_loop_max = 0; int mercator_loop_min = 0, mercator_loop_max = 0;
ld mercator_period; ld mercator_period;
auto pzero(ld t) {
if(abs(t) < 1e-6) return 2 * current_display->radius;
return t;
}
ld period_at(ld y) { ld period_at(ld y) {
ld m = current_display->radius; ld m = current_display->radius;
@ -695,12 +700,14 @@ ld period_at(ld y) {
case mdBand: case mdBand:
return m * 4; return m * 4;
case mdSinusoidal: case mdSinusoidal:
return m * 2 * cos(y * M_PI); return pzero(m * 2 * cos(y * M_PI));
case mdMollweide: case mdMollweide:
return (abs(y) > .5-1e-6) ? m * 2 : m * 2 * sqrt(1 - y*y*4); return pzero(m * 2 * sqrt(1 - y*y*4));
case mdCollignon: case mdCollignon: {
// return (y < -.499999) ? m*2 : m*(1+2*y); if(vid.collignon_reflected && y > 0) y = -y;
return (abs(y) < 1e-6) ? m*2 : m*2*y; // y = signed_sqrt(sin_auto(y) + whatever[0]); y += signed_sqrt(vid.collignon_parameter);
return pzero(abs(m*y*2/1.2));
}
default: default:
return m * 2; return m * 2;
} }

View File

@ -310,6 +310,8 @@ hyperpoint compute_hybrid(hyperpoint H, int rootid) {
return ret; return ret;
} }
EX ld signed_sqrt(ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); };
EX void applymodel(hyperpoint H, hyperpoint& ret) { EX void applymodel(hyperpoint H, hyperpoint& ret) {
hyperpoint H_orig = H; hyperpoint H_orig = H;
@ -682,23 +684,15 @@ EX void applymodel(hyperpoint H, hyperpoint& ret) {
break; break;
case mdCollignon: case mdCollignon:
find_zlev(H); /* does not look nicely otherwise */ find_zlev(H);
if(hyperbolic) H = ypush(-1) * H;
makeband(H, ret, [] (ld& x, ld& y) { makeband(H, ret, [] (ld& x, ld& y) {
auto signed_sqrt = [] (ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); }; ld sgn = 1;
/* if(vid.collignon_reflected && y > 0) y = -y, sgn = -1;
if(sphere) { y = signed_sqrt(sin_auto(y) + vid.collignon_parameter);
y = M_PI / 2 - y; x *= y / 1.2;
x = sin_auto(y/2) * x; y -= signed_sqrt(vid.collignon_parameter);
y = (sin_auto(y/2) - .5) * M_PI; y *= sgn;
} y *= M_PI;
if(hyperbolic) {
ld mul = signed_sqrt(sinh(y) + 1);
x *= mul;
y = mul + signed_sqrt(sinh(1) + 1);
}*/
y = signed_sqrt(sin_auto(y) + whatever[0]);
x *= y;
}); });
break; break;

View File

@ -554,6 +554,18 @@ EX namespace models {
}); });
} }
if(pmodel == mdCollignon) {
dialog::addSelItem(XLAT("parameter"), fts(vid.collignon_parameter) + (vid.collignon_reflected ? " (r)" : ""), 'b');
dialog::add_action([](){
dialog::editNumber(vid.collignon_parameter, -1, 1, .1, 1, XLAT("parameter"),
""
);
dialog::extra_options = [] {
dialog::addBoolItem_action(XLAT("reflect"), vid.collignon_reflected, 'R');
};
});
}
if(pmodel == mdSpiral && !euclid) { if(pmodel == mdSpiral && !euclid) {
dialog::addSelItem(XLAT("spiral angle"), fts(spiral_angle) + "°", 'x'); dialog::addSelItem(XLAT("spiral angle"), fts(spiral_angle) + "°", 'x');
dialog::add_action([](){ dialog::add_action([](){