From f6f37b1e45c87566d2c780f938fab9ee8ebcee52 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 27 Aug 2019 18:59:26 +0200 Subject: [PATCH] Archimedean precise analyzer --- archimedean.cpp | 26 ++++++++++++++++++++++++++ geom-exp.cpp | 12 +++++++++++- geometry.cpp | 8 ++------ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/archimedean.cpp b/archimedean.cpp index 8a09de8a..18a6e699 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -72,6 +72,8 @@ struct archimedean_tiling { geometryinfo1& get_geometry(); eGeometryClass get_class() { return get_geometry().kind; } + + bool get_step_values(int& steps, int& single_step); ld scale(); }; @@ -1232,6 +1234,10 @@ EX void show() { } else dialog::addBreak(100); + int s, ss; + bool b = current.get_step_values(s, ss); + println(hlog, "b=", b, " s=", s, " ss=",ss); + if(archimedean) { dialog::addSelItem(XLAT("variations"), gp::operation_name(), 'v'); dialog::add_action(next_variation); @@ -1301,6 +1307,26 @@ EX bool is_vertex(heptagon *h) { return id_of(h) >= 2 * current.N; } +bool archimedean_tiling::get_step_values(int& steps, int& single_step) { + + int nom = -2; + int denom = 1; + + for(int f: arcm::current.faces) { + if(int(denom*f)/f != denom) { steps = 0; single_step = 0; return false; } + nom = nom * f + (f-2) * denom; + denom = denom * f; + int g = gcd(nom, denom); + nom /= g; + denom /= g; + } + + steps = 2 * abs(denom); + single_step = abs(nom); + if(steps/2 != abs(denom)) return false; + return (2 * denom) % nom == 0; + } + EX int valence() { if(PURE) return arcm::current.N; if(BITRUNCATED) return 3; diff --git a/geom-exp.cpp b/geom-exp.cpp index 26fcef9c..b817f44f 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -444,7 +444,17 @@ void ge_select_tiling(const vector& lst) { if(archimedean) ok = PURE; else if(binarytiling || penrose) ok = false; else ok = PURE || BITRUNCATED; - if(!ok) addMessage(XLAT("Only works with (semi-)regular tilings")); + if(!ok) { + addMessage(XLAT("Only works with (semi-)regular tilings")); + return; + } + if(archimedean) { + int steps, single_step; + if(!arcm::current.get_step_values(steps, single_step)) { + addMessage(XLAT("That would have %1/%2 levels", its(steps), its(single_step))); + return; + } + } } set_geometry(targetgeometry); start_game(); diff --git a/geometry.cpp b/geometry.cpp index 183c24fd..0692ffbd 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -576,12 +576,8 @@ void geometry_information::prepare_basics() { steps = 0; single_step = 1; if(hybri && !prod) { - if(hybrid::underlying == gArchimedean) { - ld s = arcm::current.euclidean_angle_sum - 2; - single_step = 2; - DEBB(DF_GEOM | DF_POLY, ("1/s = ", 1/s)); - steps = 4/abs(s) + .5; - } + if(hybrid::underlying == gArchimedean) + arcm::current.get_step_values(steps, single_step); else { single_step = S3 * S7 - 2 * S7 - 2 * S3; steps = 2 * S7;