From 64cb6772e8765cfc13e0f1df400f4d77075364b5 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 20 Aug 2020 16:02:34 +0200 Subject: [PATCH] three new projections --- classes.cpp | 7 ++++-- drawing.cpp | 17 ++++++++++++- hypgraph.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ models.cpp | 4 +-- 4 files changed, 92 insertions(+), 5 deletions(-) diff --git a/classes.cpp b/classes.cpp index 29952d89..a6cb83c7 100644 --- a/classes.cpp +++ b/classes.cpp @@ -973,8 +973,8 @@ enum eModel : int { // 20..24 mdEquivolume, mdCentralInversion, mdSimulatedPerspective, mdTwoHybrid, mdGeodesic, // 25 - mdMollweide, mdCentralCyl, mdCollignon, mdHorocyclic, - // 29.. + mdMollweide, mdCentralCyl, mdCollignon, mdHorocyclic, mdQuadrant, mdAxial, mdAntiAxial, + // 32.. mdGUARD, mdPixel, mdHyperboloidFlat, mdPolynomial, mdManual }; #endif @@ -1016,6 +1016,9 @@ EX vector mdinf = { {X3("central cylindrical"), mf::euc_boring | mf::band, DEFAULTS}, {X3("Collignon"), mf::pseudoband | mf::equiarea, DEFAULTS}, {X3("horocyclic coordinates"), mf::euc_boring, DEFAULTS}, + {X3("quadrant coordinates"), mf::euc_boring, DEFAULTS}, + {X3("axial coordinates"), mf::euc_boring, DEFAULTS}, + {X3("anti-axial coordinates"), mf::euc_boring, DEFAULTS}, {X3("guard"), 0, DEFAULTS}, {X3("polynomial"), mf::conformal, DEFAULTS}, }; diff --git a/drawing.cpp b/drawing.cpp index a4a33a2c..2cde2b00 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -262,14 +262,19 @@ void add1(const hyperpoint& H) { glcoords.push_back(glhr::pointtogl(H)); } +int axial_sign() { + return ((axial_x ^ axial_y)&1) ? -1:1; + } + bool is_behind(const hyperpoint& H) { + if(pmodel == mdAxial && sphere) return axial_sign() * H[2] <= BEHIND_LIMIT; return pmodel == mdDisk && (hyperbolic ? H[2] >= 0 : true) && (nonisotropic ? false : pconf.alpha + H[2] <= BEHIND_LIMIT); } hyperpoint be_just_on_view(const hyperpoint& H1, const hyperpoint &H2) { // H1[2] * t + H2[2] * (1-t) == BEHIND_LIMIT - pconf.alpha // H2[2]- BEHIND_LIMIT + pconf.alpha = t * (H2[2] - H1[2]) - ld t = (H2[2] - BEHIND_LIMIT + pconf.alpha) / (H2[2] - H1[2]); + ld t = (axial_sign() * H2[2] - BEHIND_LIMIT + (pmodel == mdAxial ? 0 : pconf.alpha)) / (H2[2] - H1[2]) * axial_sign(); return H1 * t + H2 * (1-t); } @@ -2136,6 +2141,16 @@ EX void draw_main() { } #endif } + else if(pmodel == mdAxial && sphere) { + for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE) + ptd->draw(); + for(axial_x=-4; axial_x<=4; axial_x++) + for(axial_y=-4; axial_y<=4; axial_y++) + for(auto& ptd: ptds) if(ptd->prio != PPR::OUTCIRCLE) { + ptd->draw(); + } + glflush(); + } else { DEBB(DF_GRAPH, ("draw_main1")); if(ray::in_use && !ray::comparison_mode) { diff --git a/hypgraph.cpp b/hypgraph.cpp index 108a1ba9..2a7925c5 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -343,6 +343,8 @@ hyperpoint compute_hybrid(hyperpoint H, int rootid) { EX ld signed_sqrt(ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); } +EX int axial_x, axial_y; + EX void applymodel(shiftpoint H_orig, hyperpoint& ret) { hyperpoint H = H_orig.h; @@ -486,6 +488,73 @@ EX void applymodel(shiftpoint H_orig, hyperpoint& ret) { break; } + case mdAxial: { + models::apply_orientation_yz(H[1], H[2]); + models::apply_orientation(H[0], H[1]); + + ld& mt = pconf.model_transition; + + ld z = H[LDIM]; + if(mt != 1) z += (1-mt) * pconf.alpha; + + ret[0] = H[0] / z; + ret[1] = H[1] / z; + if(GDIM == 3) ret[2] = H[2] / z; + else ret[2] = 0; + ret[3] = 1; + + if(mt) for(int i=0; i