From be949b3698df1d354b44cd1a5b222a5a1b2a8e06 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 28 Jun 2024 14:00:52 +0200 Subject: [PATCH] small_hyperboloid more universal --- drawing.cpp | 20 ++++++++++++++++++-- hypgraph.cpp | 3 +++ models.cpp | 10 ++++++---- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index e9b13163..7774c497 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -353,7 +353,8 @@ EX int get_side(const hyperpoint& H) { if(pmodel == mdRotatedHyperboles) return H[1] > 0 ? -1 : 1; if(pmodel == mdHyperboloid) { - return det2(pconf.ball() * cspin90(2, 1) * rgpushxto0(H)) > 0 ? 1 : -1; + auto H1 = H; if(sphere && pconf.small_hyperboloid) H1 = mid(H, C0); + return det2(pconf.ball() * cspin90(2, 1) * rgpushxto0(H1)) > 0 ? 1 : -1; } if(pmodel == mdHyperboloidFlat && sphere) return H[2] >= 0 ? 1 : -1; @@ -364,6 +365,7 @@ EX int get_side(const hyperpoint& H) { } if(pmodel == mdHemisphere && sphere) { auto H1 = H; + if(pconf.small_hyperboloid) H1 = mid(H, C0); int s = H1[2] > 0 ? 1 : -1; if(hemi_side && s != hemi_side) return -spherespecial; H1[0] /= H1[2]; H1[1] /= H1[2]; @@ -570,6 +572,16 @@ void addpoly(const shiftmatrix& V, const vector &tab, int ofs, int cnt for(auto& p: tofix) fixpoint(glcoords[p.first], p.second); + + if(sphere && among(pmodel, mdHemisphere, mdHyperboloid) && pconf.small_hyperboloid) { + bool left = false, right = false; + for(auto h: glcoords) { hyperpoint h1; applymodel(shiftless(glhr::gltopoint(h)), h1); + if(h1[0] < -0) left = true; + if(h1[0] > +0) right = true; + } + if(left && right) poly_flags |= POLY_NIF_ERROR; + } + /* hyperpoint Hscr; applymodel(goodpoint, Hscr); @@ -2016,6 +2028,8 @@ void dqi_poly::draw() { if(pmodel == mdDisk && hyperbolic && pconf.alpha <= -1) can_have_inverse = true; if(pmodel == mdSpiral && pconf.skiprope) can_have_inverse = true; if(pmodel == mdCentralInversion) can_have_inverse = true; + + if(among(pmodel, mdHemisphere, mdHyperboloid) && sphere && pconf.small_hyperboloid) can_have_inverse = true; if(can_have_inverse && !(poly_flags & POLY_ISSIDE)) { @@ -2035,6 +2049,8 @@ void dqi_poly::draw() { } else poly_flags &=~ POLY_INVERSE; + + if(among(pmodel, mdHemisphere, mdHyperboloid) && sphere && pconf.small_hyperboloid && (poly_flags & POLY_INVERSE)) return; if(spherespecial) { if(!(poly_flags & POLY_INFRONT)) return; @@ -2433,7 +2449,7 @@ EX void draw_main() { return; } - if(pmodel == mdHemisphere && sphere && hemi_side == 0 && !vrhr::rendering()) { + if(pmodel == mdHemisphere && sphere && hemi_side == 0 && !vrhr::rendering() && !pconf.small_hyperboloid) { hemi_side = (pconf.ball() * hyperpoint(0,1,0,1)) [2] < 0 ? 1 : -1; draw_main(); diff --git a/hypgraph.cpp b/hypgraph.cpp index 855e18af..7032c7df 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -925,6 +925,7 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { switch(cgclass) { case gcHyperbolic: { + if(pconf.small_hyperboloid) H = mid(C0, H); ld zl = zlevel(H); ret = H / H[2]; ret[2] = sqrt(1 - sqhypot_d(2, ret)); @@ -944,11 +945,13 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { ret[2] = (1 - y); ret[2] *= dir; ret = ret * (1 + (H[2]-1) * y * pconf.depth_scaling * dir / pconf.euclid_to_sphere); + if(pconf.small_hyperboloid) { ret = ret - C0; ret = ret / hypot_d(3, ret); } } break; } case gcSphere: { + if(pconf.small_hyperboloid) H = mid(C0, H); if(vrhr::rendering()) { vr_sphere(ret, H, md); return; } ld z = sqhypot_d(3, H); int s = H[2] > 0 ? 1 : -1; diff --git a/models.cpp b/models.cpp index bc3a2aea..73067c2a 100644 --- a/models.cpp +++ b/models.cpp @@ -425,6 +425,7 @@ EX namespace models { USING_NATIVE_GEOMETRY_IN_RUG; #endif dialog::init(XLAT("models & projections")); + mouseovers = XLAT("see http://www.roguetemple.com/z/hyper/models.php"); auto vpmodel = vpconf.model; @@ -626,10 +627,11 @@ EX namespace models { add_edit(vpconf.fisheye_alpha); } - if(is_hyperboloid(vpmodel)) { + if(is_hyperboloid(vpmodel)) add_edit(pconf.show_hyperboloid_flat); + + if(among(vpmodel, mdHyperboloid, mdHemisphere)) add_edit(pconf.small_hyperboloid); - } if(vpmodel == mdCollignon) add_edit(vpconf.collignon_parameter); @@ -1045,8 +1047,8 @@ EX namespace models { -> editable("show flat", 'b'); param_b(p.small_hyperboloid, sp+"hyperboloid-small", false) - -> editable("small hyperboloid model", 't') - -> help("as in Clifford algebras"); + -> editable("halve distances", 'h') + -> help("This option halves the distances of every point from the center. Useful in the Minkowski hyperboloid model, to get a visualization of an alternative hyperboloid model based on Clifford algebras."); param_f(p.skiprope, sp+"mobius", 0) -> editable(0, 360, 15, "Möbius transformations", "", 'S')->unit = "°";