From 999eec66502822617fedc2764342971c79fab407 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 27 Nov 2019 01:03:57 +0100 Subject: [PATCH] irregular maps in Euclidean --- euclid.cpp | 5 ++++- irregular.cpp | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/euclid.cpp b/euclid.cpp index 4d2a8898..32d80b3e 100644 --- a/euclid.cpp +++ b/euclid.cpp @@ -122,7 +122,10 @@ EX namespace euclid3 { return spacemap[at]; else { auto h = tailored_alloc (S7); - h->c7 = newCell(S7, h); + if(!IRREGULAR) + h->c7 = newCell(S7, h); + else + irr::link_to_base(h, ((hrmap_euclid3*)irr::base)->get_at(at)); h->distance = 0; h->cdata = NULL; h->alt = NULL; diff --git a/irregular.cpp b/irregular.cpp index 42998bf4..9f645134 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -45,7 +45,8 @@ EX vector cells; ld inner(hyperpoint h1, hyperpoint h2) { return hyperbolic ? h1[LDIM] * h2[LDIM] - h1[0] * h2[0] - h1[1] * h2[1] : - h1[LDIM] * h2[LDIM] + h1[0] * h2[0] + h1[1] * h2[1]; + sphere ? h1[LDIM] * h2[LDIM] + h1[0] * h2[0] + h1[1] * h2[1] : + h1[0] * h2[0] + h1[1] * h2[1]; } hyperpoint circumscribe(hyperpoint a, hyperpoint b, hyperpoint c) { @@ -54,6 +55,20 @@ hyperpoint circumscribe(hyperpoint a, hyperpoint b, hyperpoint c) { b = b - a; c = c - a; + if(euclid) { + ld b2 = inner(b, b)/2; + ld c2 = inner(c, c)/2; + + ld det = c[1]*b[0] - b[1]*c[0]; + + h = a; + + h[1] += (c2*b[0] - b2 * c[0]) / det; + h[0] += (c2*b[1] - b2 * c[1]) / -det; + + return h; + } + if(inner(b,b) < 0) { b = b / sqrt(-inner(b, b)); c = c + b * inner(c, b); @@ -104,7 +119,7 @@ void make_cells_of_heptagon() { string status[5]; -hrmap *base; +EX hrmap *base; bool gridmaking; @@ -1077,6 +1092,7 @@ EX bool ctof(cell* c) { } EX bool supports(eGeometry g) { + if(g == gEuclid || g == gEuclidSquare) return ginf[g].flags & qBOUNDED; return among(g, gNormal, gKleinQuartic, gOctagon, gBolza2, gFieldQuotient, gSphere, gSmallSphere, gTinySphere); }