From 4c6c44cc26d72229320b77178af1b70a9130b610 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 7 Jan 2024 12:52:50 +0100 Subject: [PATCH] variant fisheye projection --- classes.cpp | 3 ++- graph.cpp | 2 +- help.cpp | 3 ++- hypgraph.cpp | 25 +++++++++++++++++++++++-- models.cpp | 12 ++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/classes.cpp b/classes.cpp index 3b83d1f1..0e38ceab 100644 --- a/classes.cpp +++ b/classes.cpp @@ -1031,7 +1031,7 @@ enum eModel : int { // 39..48 mdPoorMan, mdPanini, mdRetroCraig, mdRetroLittrow, mdRetroHammer, mdThreePoint, mdLiePerspective, mdLieOrthogonal, mdRelPerspective, mdRelOrthogonal, // 49..50 - mdHorocyclicEqa, mdConformalSquare, + mdHorocyclicEqa, mdConformalSquare, mdFisheye2, // 51.. mdGUARD, mdPixel, mdHyperboloidFlat, mdPolynomial, mdManual }; @@ -1095,6 +1095,7 @@ EX vector mdinf = { {X3("relativistic orthogonal"), mf::euc_boring}, {X3("horocyclic equal-area"), mf::euc_boring | mf::equiarea | mf::orientation | mf::horocyclic}, {X3("conformal square"), mf::orientation | mf::broken | mf::transition}, + {X3("variant fisheye"), 0}, {X3("guard"), mf::technical}, {X3("pixel"), mf::technical}, {X3("hypflat"), mf::technical}, diff --git a/graph.cpp b/graph.cpp index ab6aff13..7bfc59d0 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3273,7 +3273,7 @@ EX int haveaura() { if(sphere && mdAzimuthalEqui()) return 0; if(among(pmodel, mdJoukowsky, mdJoukowskyInverted) && hyperbolic && pconf.model_transition < 1) return 2; - if(pmodel == mdFisheye) return 1; + if(among(pmodel, mdFisheye, mdFisheye2)) return 1; return pmodel == mdDisk && (!sphere || pconf.alpha > 10) && !euclid; } diff --git a/help.cpp b/help.cpp index db9895c3..240b2f6e 100644 --- a/help.cpp +++ b/help.cpp @@ -240,7 +240,8 @@ EX void buildCredits() { "Kojiguchi Kazuki, baconcow, Alan, SurelyYouJest, hotdogPi, DivisionByZero, xXxWeedGokuxXx, jpystynen, Dmitry Marakasov, Alexandre Moine, Arthur O'Dwyer, " "Triple_Agent_AAA, bluetailedgnat, Allalinor, Shitford, KittyTac, Christopher King, KosGD, TravelDemon, Bubbles, rdococ, frozenlake, MagmaMcFry, " "Snakebird Priestess, roaringdragon2, Stopping Dog, bengineer8, Sir Light IJIJ, ShadeBlade, Saplou, shnourok, Ralith, madasa, 6% remaining, Chimera245, Remik Pi, alien foxcat thing, " - "Piotr Grochowski, Ann, still-flow, tyzone, Paradoxica, LottieRatWorld, aismallard, albatross, EncodedSpirit, Jacob Mandelson, CrashTuvai, cvoight, jennlbw, Kali Ranya, spiritbackup, Dylan, L_Lord, AntiRogue" + "Piotr Grochowski, Ann, still-flow, tyzone, Paradoxica, LottieRatWorld, aismallard, albatross, EncodedSpirit, Jacob Mandelson, CrashTuvai, cvoight, jennlbw, Kali Ranya, spiritbackup, Dylan, L_Lord, AntiRogue, " + "masonlgreen" ); #ifdef EXTRALICENSE help += EXTRALICENSE; diff --git a/hypgraph.cpp b/hypgraph.cpp index b1deea27..ea702dcf 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1055,6 +1055,27 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { break; } + case mdFisheye2: { + ld zlev; + if(nonisotropic) { + H = lp_apply(inverse_exp(H_orig)); + zlev = 1; + } + else { + zlev = find_zlev(H); + H = space_to_perspective(H); + } + H /= pconf.fisheye_param; + auto H1 = perspective_to_space(H, pconf.fisheye_alpha, gcSphere); + auto H2 = perspective_to_space(hyperpoint(1e6, 0, 0, 0), pconf.fisheye_alpha, gcSphere); + H1[2] += 1; + H1 /= H1[2]; + H1 /= H2[0] / (H2[2]+1); + ret = H1; + if(GDIM == 3) ret[LDIM] = zlev; + break; + } + case mdSimulatedPerspective: { models::scr_to_ori(H); auto yz = move_z_to_y(H); @@ -2475,7 +2496,7 @@ EX transmatrix atscreenpos(ld x, ld y, ld size) { void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio) { #if CAP_QUEUE - if(among(pmodel, mdDisk, mdEquiarea, mdEquidistant, mdFisheye) && !(pmodel == mdDisk && hyperbolic && pconf.alpha <= -1) && models::camera_straight) { + if(among(pmodel, mdDisk, mdEquiarea, mdEquidistant, mdFisheye, mdFisheye2) && !(pmodel == mdDisk && hyperbolic && pconf.alpha <= -1) && models::camera_straight) { hyperpoint ret; applymodel(shiftless(xpush0(radius)), ret); ld r = hypot_d(2, ret); @@ -2733,7 +2754,7 @@ EX void draw_boundary(int w) { } if(w == 1) return; - if(nonisotropic || (euclid && !among(pmodel, mdFisheye, mdConformalSquare, mdHemisphere)) || gproduct) return; + if(nonisotropic || (euclid && !among(pmodel, mdFisheye, mdFisheye2, mdConformalSquare, mdHemisphere)) || gproduct) return; #if CAP_VR if(vrhr::active() && pmodel == mdHyperboloid) return; #endif diff --git a/models.cpp b/models.cpp index fd6a728e..e413a104 100644 --- a/models.cpp +++ b/models.cpp @@ -619,6 +619,11 @@ EX namespace models { if(vpmodel == mdFisheye) add_edit(vpconf.fisheye_param); + if(vpmodel == mdFisheye2) { + add_edit(vpconf.fisheye_param); + add_edit(vpconf.fisheye_alpha); + } + if(is_hyperboloid(vpmodel)) add_edit(pconf.show_hyperboloid_flat); @@ -974,6 +979,13 @@ EX namespace models { -> editable(1e-3, 10, .1, "fisheye parameter", "Size of the fish eye.", 'b') -> set_sets(dialog::scaleLog); + param_f(p.fisheye_alpha, pp+"fishalpha", sp+"off-center parameter", 0) + -> editable(1e-1, 10, .1, "off-center parameter", + "This projection is obtained by composing gnomonic projection and inverse stereographic projection. " + "This parameter changes the center of the first projection (0 = gnomonic, 1 = stereographic). Use a value closer to 1 " + "to make the projection more conformal.", + 'o'); + param_f(p.stretch, pp+"stretch", 1) -> editable(0, 10, .1, "vertical stretch", "Vertical stretch factor.", 's') -> set_extra(stretch_extra);