2019-08-10 11:43:24 +00:00
|
|
|
// Hyperbolic Rogue -- Archimedean Tilings
|
|
|
|
// Copyright (C) 2011-2019 Zeno Rogue, see 'hyper.cpp' for details
|
|
|
|
|
|
|
|
/** \file archimedean.cpp
|
|
|
|
* \brief Archimedean tilings
|
|
|
|
*
|
|
|
|
* These are tilings available in the 'Archimedean' option in Geometry Experiments; simpler Archimedean tilings are defined in other files.
|
|
|
|
*/
|
2018-12-02 22:08:44 +00:00
|
|
|
|
2019-09-05 07:15:40 +00:00
|
|
|
#include "hyper.h"
|
2018-08-17 11:29:00 +00:00
|
|
|
namespace hr {
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX namespace arcm {
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2019-12-14 10:42:16 +00:00
|
|
|
EX bool in() { return cgflags & qARCHI; }
|
|
|
|
|
2021-08-05 10:21:39 +00:00
|
|
|
EX ld euclidean_edge_length = .5;
|
|
|
|
|
2019-08-09 19:18:13 +00:00
|
|
|
#if HDR
|
2021-07-04 07:32:29 +00:00
|
|
|
struct hr_archimedean_error : hr_exception {
|
|
|
|
hr_archimedean_error(string _s) : hr_exception(_s) {}
|
|
|
|
};
|
|
|
|
|
2019-08-09 19:18:13 +00:00
|
|
|
struct archimedean_tiling {
|
|
|
|
|
|
|
|
int coloring;
|
|
|
|
|
|
|
|
string symbol;
|
|
|
|
|
|
|
|
vector<int> faces;
|
|
|
|
vector<int> adj;
|
|
|
|
vector<bool> invert;
|
|
|
|
vector<int> nflags;
|
|
|
|
|
|
|
|
bool have_ph, have_line, have_symmetry;
|
|
|
|
int real_faces;
|
|
|
|
int real_face_type;
|
|
|
|
|
|
|
|
int repetition;
|
|
|
|
int N;
|
2020-07-03 13:40:26 +00:00
|
|
|
|
|
|
|
bool regular;
|
2019-08-09 19:18:13 +00:00
|
|
|
|
|
|
|
ld euclidean_angle_sum;
|
|
|
|
|
|
|
|
vector<int> flags;
|
|
|
|
|
|
|
|
vector<vector<pair<int, int>>> adjacent;
|
|
|
|
vector<vector<pair<ld, ld>>> triangles;
|
|
|
|
|
|
|
|
void make_match(int a, int i, int b, int j);
|
|
|
|
void prepare();
|
2020-03-22 10:27:06 +00:00
|
|
|
void compute_sum();
|
2019-08-09 19:18:13 +00:00
|
|
|
void compute_geometry();
|
|
|
|
|
|
|
|
void parse();
|
|
|
|
void parse(string s) { symbol = s; parse(); }
|
|
|
|
|
|
|
|
ld edgelength;
|
|
|
|
|
|
|
|
vector<ld> inradius, circumradius, alphas;
|
|
|
|
|
2020-01-18 15:03:32 +00:00
|
|
|
vector<vector<int>> matches;
|
|
|
|
vector<int> periods;
|
|
|
|
vector<int> tilegroup;
|
|
|
|
vector<int> groupoffset;
|
|
|
|
int tilegroups;
|
2019-08-09 19:18:13 +00:00
|
|
|
|
|
|
|
int errors;
|
|
|
|
string errormsg;
|
|
|
|
|
|
|
|
pair<int, int>& get_adj(heptagon *h, int cid);
|
|
|
|
pair<int, int>& get_adj(heptspin hs) { return get_adj(hs.at, hs.spin); }
|
|
|
|
pair<ld, ld>& get_triangle(heptagon *h, int cid);
|
|
|
|
pair<ld, ld>& get_triangle(heptspin hs) { return get_triangle(hs.at, hs.spin); }
|
|
|
|
pair<ld, ld>& get_triangle(const pair<int, int>& p, int delta = 0);
|
|
|
|
pair<int, int>& get_adj(const pair<int, int>& p, int delta = 0);
|
|
|
|
|
|
|
|
int support_threecolor();
|
|
|
|
int support_threecolor_bitruncated();
|
|
|
|
int support_football();
|
|
|
|
bool support_chessboard();
|
|
|
|
void regroup();
|
|
|
|
string world_size();
|
2019-08-26 13:38:20 +00:00
|
|
|
void get_nom_denom(int& anom, int& adenom);
|
2019-08-09 19:18:13 +00:00
|
|
|
|
2020-05-31 14:18:44 +00:00
|
|
|
geometryinfo1& get_geometry(ld mul = 1);
|
2019-08-22 10:14:39 +00:00
|
|
|
eGeometryClass get_class() { return get_geometry().kind; }
|
2019-08-27 16:59:26 +00:00
|
|
|
|
|
|
|
bool get_step_values(int& steps, int& single_step);
|
2020-05-31 14:18:44 +00:00
|
|
|
|
|
|
|
transmatrix adjcell_matrix(heptagon *h, int d);
|
2019-08-09 19:18:13 +00:00
|
|
|
|
|
|
|
ld scale();
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-12-27 21:59:50 +00:00
|
|
|
#if HDR
|
2018-08-19 13:15:47 +00:00
|
|
|
static const int sfPH = 1;
|
|
|
|
static const int sfLINE = 2;
|
2018-08-19 16:06:54 +00:00
|
|
|
static const int sfCHESS = 4;
|
|
|
|
static const int sfTHREE = 8;
|
2018-08-21 15:54:53 +00:00
|
|
|
static const int sfSEMILINE = 16;
|
2019-12-27 21:59:50 +00:00
|
|
|
#endif
|
2018-08-19 13:15:47 +00:00
|
|
|
|
2020-10-15 14:33:52 +00:00
|
|
|
#if CAP_ARCM
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX archimedean_tiling current;
|
2020-05-31 14:18:44 +00:00
|
|
|
EX archimedean_tiling fake_current;
|
|
|
|
|
|
|
|
EX archimedean_tiling& current_or_fake() {
|
|
|
|
if(fake::in()) return fake_current;
|
|
|
|
return current;
|
|
|
|
}
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2019-08-10 11:43:24 +00:00
|
|
|
/** id of vertex in the archimedean tiling
|
|
|
|
* odd numbers = reflected tiles
|
|
|
|
* 0, 2, ..., 2(N-1) = as in the symbol
|
|
|
|
* 2N = bitruncated tile
|
|
|
|
*/
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX short& id_of(heptagon *h) {
|
2018-08-17 11:29:00 +00:00
|
|
|
return h->zebraval;
|
|
|
|
}
|
|
|
|
|
2019-08-10 11:43:24 +00:00
|
|
|
/** which index in id_of's neighbor list does h->move(0) have */
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX short& parent_index_of(heptagon *h) {
|
2018-08-17 11:29:00 +00:00
|
|
|
return h->emeraldval;
|
|
|
|
}
|
|
|
|
|
2019-08-10 11:43:24 +00:00
|
|
|
/** total number of neighbors */
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int neighbors_of(heptagon *h) {
|
2018-08-20 00:02:45 +00:00
|
|
|
return isize(current.triangles[id_of(h)]);
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int gcd(int x, int y) { return x ? gcd(y%x, x) : y < 0 ? -y : y; }
|
2018-08-19 11:47:51 +00:00
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
void archimedean_tiling::make_match(int a, int i, int b, int j) {
|
2018-08-19 20:53:34 +00:00
|
|
|
if(isize(adjacent[a]) != isize(adjacent[b])) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, ("(error here)"));
|
2018-08-19 20:53:34 +00:00
|
|
|
errormsg = XLAT("polygons match incorrectly");
|
2018-08-19 11:47:51 +00:00
|
|
|
errors++;
|
2018-08-19 20:53:34 +00:00
|
|
|
}
|
2018-08-19 11:47:51 +00:00
|
|
|
if(matches[a][b] == -1)
|
|
|
|
matches[a][b] = j - i, matches[b][a] = i - j;
|
|
|
|
else
|
|
|
|
periods[a] = periods[b] = gcd(matches[a][b] - (j-i), periods[a]);
|
|
|
|
}
|
|
|
|
|
2020-01-18 15:03:32 +00:00
|
|
|
/** mostly to protect the user from entering too large numbers */
|
|
|
|
const int MAX_EDGE_ARCM = FULL_EDGE;
|
|
|
|
|
2022-04-21 19:50:40 +00:00
|
|
|
/** compute the edge length of an Archimedean tiling. Each element of facemul is (face sides, multiplicity) */
|
|
|
|
EX ld compute_edgelength(vector<pair<ld, ld>> facemul, ld halftotal IS(M_PI)) {
|
|
|
|
ld elmin = 0, elmax = hyperbolic ? 10 : sphere ? M_PI : 2 * euclidean_edge_length;
|
|
|
|
ld edgelength;
|
|
|
|
for(int p=0; p<100; p++) {
|
|
|
|
edgelength = (elmin + elmax) / 2;
|
|
|
|
ld alpha_total = 0;
|
|
|
|
for(auto fm: facemul) {
|
2022-04-21 20:09:23 +00:00
|
|
|
if(isinf(fm.first)) {
|
|
|
|
ld u = sqrt(cosh(edgelength) * 2 - 2);
|
|
|
|
ld a = atan2(1, u/2);
|
|
|
|
alpha_total += a * fm.second;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ld gamma = M_PI / fm.first;
|
|
|
|
auto c = asin_auto(sin_auto(edgelength/2) / sin(gamma));
|
2022-12-08 18:38:06 +00:00
|
|
|
hyperpoint h = lxpush(c) * spin(M_PI - 2*gamma) * lxpush0(c);
|
2022-04-21 20:09:23 +00:00
|
|
|
ld a = atan2(h);
|
|
|
|
cyclefix(a, 0);
|
|
|
|
if(a < 0) a = -a;
|
|
|
|
alpha_total += a * fm.second;
|
|
|
|
}
|
2022-04-21 19:50:40 +00:00
|
|
|
}
|
|
|
|
if(isnan(alpha_total)) elmax = edgelength;
|
|
|
|
else if(sphere ^ (alpha_total > halftotal)) elmin = edgelength;
|
|
|
|
else elmax = edgelength;
|
|
|
|
}
|
|
|
|
return edgelength;
|
|
|
|
}
|
|
|
|
|
2020-03-22 10:27:06 +00:00
|
|
|
void archimedean_tiling::compute_sum() {
|
|
|
|
N = isize(faces);
|
2018-08-22 23:52:29 +00:00
|
|
|
euclidean_angle_sum = 0;
|
|
|
|
for(int f: faces) euclidean_angle_sum += (f-2.) / f;
|
|
|
|
|
2020-03-22 10:27:06 +00:00
|
|
|
real_faces = 0, real_face_type = 0;
|
|
|
|
for(int i=0; i<N; i++) if(faces[i] > 2) real_faces++, real_face_type += faces[i];
|
|
|
|
real_face_type /= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void archimedean_tiling::prepare() {
|
|
|
|
|
|
|
|
compute_sum();
|
|
|
|
|
2020-01-18 15:03:32 +00:00
|
|
|
for(int i: faces) if(i > MAX_EDGE_ARCM) {
|
|
|
|
errormsg = XLAT("currently no more than %1 edges", its(MAX_EDGE_ARCM));
|
2018-08-19 20:53:34 +00:00
|
|
|
errors++;
|
|
|
|
return;
|
|
|
|
}
|
2020-01-18 15:03:32 +00:00
|
|
|
if(isize(faces) > MAX_EDGE_ARCM/2) {
|
|
|
|
errormsg = XLAT("currently no more than %1 faces in vertex", its(MAX_EDGE_ARCM/2));
|
2018-08-19 20:53:34 +00:00
|
|
|
errors++;
|
|
|
|
return;
|
|
|
|
}
|
2020-09-16 18:32:26 +00:00
|
|
|
|
|
|
|
for(int i: faces) if(i < 2) {
|
|
|
|
errormsg = XLAT("not enough edges");
|
|
|
|
errors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<int> nondigonal;
|
|
|
|
for(int i: faces) if(i > 2) nondigonal.push_back(i);
|
|
|
|
|
|
|
|
if(isize(faces) < 2 || isize(nondigonal) == 1) {
|
2018-08-19 20:53:34 +00:00
|
|
|
errormsg = XLAT("not enough faces");
|
|
|
|
errors++;
|
|
|
|
return;
|
|
|
|
}
|
2020-09-16 18:32:26 +00:00
|
|
|
|
|
|
|
if(isize(nondigonal) == 2 && faces[0] != faces[1]) {
|
|
|
|
errormsg = XLAT("invalid dihedron");
|
2018-08-19 20:53:34 +00:00
|
|
|
errors++;
|
|
|
|
return;
|
|
|
|
}
|
2020-03-29 09:59:03 +00:00
|
|
|
|
|
|
|
for(int i=0; i<N; i++) {
|
|
|
|
bool forward = false;
|
|
|
|
int f = faces[i];
|
|
|
|
int i0 = i;
|
|
|
|
for(int k=0; k<f; k++) {
|
|
|
|
forward ^= invert[i0];
|
|
|
|
i0 = adj[i0];
|
|
|
|
if(forward) { if(faces[i0] != f) { errormsg = XLAT("face mismatch"); errors++; return; } i0++; if(i0 == N) i0 = 0; }
|
|
|
|
else { if(i0 == 0) i0 = N; i0--; if(faces[i0] != f) { errormsg = XLAT("face mismatch"); errors++; return; } }
|
|
|
|
}
|
|
|
|
for(int k=0; k<N; k++) {
|
|
|
|
f = faces[(i+N-k-1) % N];
|
|
|
|
if(forward) { if(faces[i0] != f) { errormsg = XLAT("face mismatch II "); errors++; return; } i0++; if(i0 == N) i0 = 0; }
|
|
|
|
else { if(i0 == 0) i0 = N; i0--; if(faces[i0] != f) { errormsg = XLAT("face mismatch II"); errors++; return; } }
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 20:53:34 +00:00
|
|
|
|
2018-08-21 17:05:05 +00:00
|
|
|
if(real_faces) {
|
|
|
|
for(int i=1; i<isize(faces); i++) if(faces[i] == 2 && faces[i-1] == 2) {
|
|
|
|
errormsg = XLAT("Not implemented.");
|
|
|
|
errors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(faces[0] == 2 && faces[isize(faces)-1] == 2) {
|
|
|
|
errormsg = XLAT("Not implemented.");
|
|
|
|
errors++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-21 15:55:17 +00:00
|
|
|
if(real_faces == 2) {
|
|
|
|
for(int i: faces) if(i != real_face_type) {
|
|
|
|
errormsg = XLAT("polygons match incorrectly");
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 11:47:51 +00:00
|
|
|
errors = 0;
|
|
|
|
|
2018-08-17 11:29:00 +00:00
|
|
|
/* build the 'adjacent' table */
|
|
|
|
|
2018-08-19 11:47:51 +00:00
|
|
|
int M = 2 * N + 2;
|
2018-08-17 11:29:00 +00:00
|
|
|
adjacent.clear();
|
2018-08-19 11:47:51 +00:00
|
|
|
adjacent.resize(M);
|
|
|
|
|
|
|
|
have_symmetry = false;
|
|
|
|
for(int i=0; i<N; i++) if(invert[i]) have_symmetry = true;
|
|
|
|
|
2020-01-18 15:03:32 +00:00
|
|
|
matches.resize(M);
|
|
|
|
for(int i=0; i<M; i++) {
|
|
|
|
matches[i].resize(M);
|
|
|
|
for(int j=0; j<M; j++) matches[i][j] = i==j ? 0 : -1;
|
|
|
|
}
|
2018-08-19 11:47:51 +00:00
|
|
|
|
2020-01-18 15:03:32 +00:00
|
|
|
periods.resize(M);
|
2018-08-19 11:47:51 +00:00
|
|
|
for(int i=0; i<M; i++) periods[i] = i<2*N ? faces[i/2] : N;
|
|
|
|
|
2018-08-17 11:29:00 +00:00
|
|
|
for(int i=0; i<N; i++) {
|
|
|
|
for(int oi=0; oi<1; oi++) {
|
|
|
|
int at = (i+oi)%N;
|
|
|
|
int inv = oi;
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB0(DF_GEOM, ("vertex "));
|
2018-08-17 11:29:00 +00:00
|
|
|
for(int z=0; z<faces[i]; z++) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB0(DF_GEOM, (format("[%d %d] " , at, inv)));
|
2018-08-17 11:29:00 +00:00
|
|
|
adjacent[2*i+oi].emplace_back(2*N+int(inv), inv ? (2*at+2*N-2) % (2*N) : 2*at);
|
|
|
|
if(invert[at]) inv ^= 1;
|
|
|
|
at = adj[at];
|
|
|
|
if(inv) at = (at+1) % N;
|
|
|
|
else at = (at+N-1) % N;
|
|
|
|
}
|
2018-08-21 15:54:53 +00:00
|
|
|
if(!inv) make_match(2*i, 0, inv ? (2*at+2*N-1) % 2*N : 2*at, 0);
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, (format("-> [%d %d]\n", at, inv)));
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i=0; i<N; i++) {
|
|
|
|
adjacent[2*N].emplace_back(2*i, 0);
|
|
|
|
int ai = (i+1) % N;
|
|
|
|
adjacent[2*N].emplace_back(2*N+int(invert[ai]), (2*adj[ai]+2*N-1) % (2*N));
|
|
|
|
}
|
2018-08-19 11:47:51 +00:00
|
|
|
|
2018-08-17 11:29:00 +00:00
|
|
|
for(int d=0; d<=2*N; d+=2) {
|
|
|
|
int s = isize(adjacent[d]);
|
|
|
|
for(int i=0; i<s; i++) {
|
|
|
|
auto& orig = adjacent[d][s-1-i];
|
|
|
|
adjacent[d+1].emplace_back(orig.first ^ 1, orig.second);
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 11:47:51 +00:00
|
|
|
for(int d=0; d<M; d++) {
|
2018-08-17 11:29:00 +00:00
|
|
|
int s = isize(adjacent[d]);
|
|
|
|
for(int i=0; i<s; i++) {
|
|
|
|
auto& orig = adjacent[d][i];
|
|
|
|
if(orig.first & 1) orig.second = isize(adjacent[orig.first]) - 1 - orig.second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-12 23:57:40 +00:00
|
|
|
if(debugflags & DF_GEOM) {
|
|
|
|
for(int i=0; i<M; i++) {
|
|
|
|
DEBB0(DF_GEOM, ("adjacent ", i, ":"));
|
|
|
|
for(int j=0; j<isize(adjacent[i]); j++) {
|
|
|
|
auto p = adjacent[i][j];
|
|
|
|
DEBB0(DF_GEOM, (" ", p));
|
|
|
|
}
|
|
|
|
DEBB(DF_GEOM, ("\n"));
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
2019-05-12 23:57:40 +00:00
|
|
|
}
|
2018-08-21 15:54:53 +00:00
|
|
|
|
|
|
|
for(int i=0; i<M; i++) {
|
|
|
|
for(int j=0; j<isize(adjacent[i]); j++) {
|
|
|
|
auto p = adjacent[i][j];
|
|
|
|
auto q = adjacent[p.first][p.second];
|
|
|
|
make_match(i, j, q.first, q.second);
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 11:29:00 +00:00
|
|
|
|
|
|
|
/* verify all the triangles */
|
2018-08-19 11:47:51 +00:00
|
|
|
for(int i=0; i<M; i++) {
|
2018-08-17 11:29:00 +00:00
|
|
|
for(int j=0; j<isize(adjacent[i]); j++) {
|
|
|
|
int ai = i, aj = j;
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB0(DF_GEOM, ("triangle "));
|
2018-08-17 11:29:00 +00:00
|
|
|
for(int s=0; s<3; s++) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB0(DF_GEOM, (format("[%d %d] ", ai, aj)));
|
2018-08-17 11:29:00 +00:00
|
|
|
tie(ai, aj) = adjacent[ai][aj];
|
|
|
|
aj++; if(aj >= isize(adjacent[ai])) aj = 0;
|
|
|
|
}
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, (format("-> [%d %d]\n", ai, aj)));
|
2018-08-19 11:47:51 +00:00
|
|
|
make_match(i, j, ai, aj);
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-19 11:47:51 +00:00
|
|
|
|
|
|
|
for(int i=0; i<2*N; i++) {
|
|
|
|
for(int j=0; j<isize(adjacent[i]); j++) {
|
|
|
|
auto aa = make_pair(i, j);
|
|
|
|
aa = get_adj(aa, 1);
|
|
|
|
aa = get_adj(aa, 2);
|
|
|
|
aa = get_adj(aa, 1);
|
|
|
|
aa = get_adj(aa, 2);
|
|
|
|
make_match(i, j, aa.first, aa.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-21 15:54:53 +00:00
|
|
|
regroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void archimedean_tiling::regroup() {
|
|
|
|
int M = 2 * N + 2;
|
2018-08-19 11:47:51 +00:00
|
|
|
for(int i=0; i<M; i++) for(int j=0; j<M; j++) if(matches[i][j] != -1)
|
|
|
|
for(int l=0; l<M; l++) for(int k=0; k<M; k++) if(matches[j][k] != -1) {
|
|
|
|
make_match(i, 0, k, matches[i][j] + matches[j][k]);
|
|
|
|
make_match(i, 0, k, matches[i][j] + matches[j][k] + gcd(periods[i], periods[j]));
|
|
|
|
}
|
2020-01-18 15:03:32 +00:00
|
|
|
tilegroup.clear();
|
|
|
|
tilegroup.resize(M, -1);
|
|
|
|
groupoffset.resize(M);
|
2018-08-19 11:47:51 +00:00
|
|
|
tilegroups = 0;
|
|
|
|
for(int i=0; i<M; i+=(have_symmetry?1:2)) if(tilegroup[i] == -1) {
|
|
|
|
if(periods[i] < 0) periods[i] = -periods[i];
|
|
|
|
for(int j=0; j<M; j++) if(matches[i][j] != -1)
|
|
|
|
tilegroup[j] = tilegroups, groupoffset[j] = matches[i][j] % periods[i];
|
|
|
|
tilegroups++;
|
|
|
|
}
|
2018-08-21 15:54:53 +00:00
|
|
|
|
2018-08-19 11:47:51 +00:00
|
|
|
flags.clear();
|
2020-01-28 09:29:36 +00:00
|
|
|
flags.resize(M, 0);
|
2018-08-19 11:47:51 +00:00
|
|
|
for(int i=0; i<M; i++)
|
2018-08-30 14:06:51 +00:00
|
|
|
for(int j=0; j<M; j++) {
|
2018-08-21 15:54:53 +00:00
|
|
|
if(tilegroup[i] == tilegroup[j]) {
|
|
|
|
flags[i] |= nflags[j/2];
|
|
|
|
if(j%2 == 1 && (nflags[j/2] & sfSEMILINE))
|
|
|
|
flags[i] |= sfLINE;
|
|
|
|
}
|
|
|
|
}
|
2018-08-19 11:47:51 +00:00
|
|
|
|
|
|
|
if(!have_ph) {
|
2018-08-30 14:06:51 +00:00
|
|
|
for(int i=0; i<M; i++) if(tilegroup[i] == 0) flags[i] |= sfPH;
|
2018-08-19 11:47:51 +00:00
|
|
|
}
|
2018-08-19 20:53:34 +00:00
|
|
|
|
2019-05-12 23:57:40 +00:00
|
|
|
if(debugflags & DF_GEOM) {
|
|
|
|
for(int i=0; i<M; i+=(have_symmetry?1:2)) {
|
|
|
|
DEBB(DF_GEOM, (format("tiling group of %2d: [%2d]%2d+Z%2d\n", i, tilegroup[i], groupoffset[i], periods[i])));
|
|
|
|
}
|
|
|
|
}
|
2018-08-20 00:02:45 +00:00
|
|
|
}
|
|
|
|
|
2020-05-31 14:18:44 +00:00
|
|
|
geometryinfo1& archimedean_tiling::get_geometry(ld mul) {
|
|
|
|
if(euclidean_angle_sum * mul < 1.999999) return ginf[gSphere].g;
|
|
|
|
else if(euclidean_angle_sum * mul > 2.000001) return ginf[gNormal].g;
|
2019-08-22 10:14:39 +00:00
|
|
|
else return ginf[gEuclid].g;
|
2018-08-22 23:52:29 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
void archimedean_tiling::compute_geometry() {
|
2022-12-08 18:38:06 +00:00
|
|
|
|
2022-12-08 21:05:16 +00:00
|
|
|
if(embedded_plane && geometry != gArchimedean) return;
|
2022-12-08 18:38:06 +00:00
|
|
|
if(embedded_plane) return IPF(compute_geometry());
|
|
|
|
|
2019-08-22 10:14:39 +00:00
|
|
|
ginf[gArchimedean].g = get_geometry();
|
2022-05-21 11:08:42 +00:00
|
|
|
set_flag(ginf[gArchimedean].flags, qCLOSED, get_class() == gcSphere);
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2022-12-08 18:38:06 +00:00
|
|
|
if(geom3::ginf_backup.size()) {
|
2022-12-08 20:19:59 +00:00
|
|
|
if(get_geometry().kind == gcSphere)
|
|
|
|
geom3::ginf_backup[gArchimedean].g = geom3::ginf_backup[gSphere].g;
|
|
|
|
if(get_geometry().kind == gcEuclid)
|
|
|
|
geom3::ginf_backup[gArchimedean].g = geom3::ginf_backup[gNormal].g;
|
|
|
|
if(get_geometry().kind == gcHyperbolic)
|
|
|
|
geom3::ginf_backup[gArchimedean].g = geom3::ginf_backup[gEuclid].g;
|
2022-12-08 18:38:06 +00:00
|
|
|
if(geom3::flipped) swap(geom3::ginf_backup[gArchimedean].g, ginf[gArchimedean].g);
|
|
|
|
set_flag(ginf[gArchimedean].flags, qCLOSED, get_class() == gcSphere);
|
|
|
|
}
|
|
|
|
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, (format("euclidean_angle_sum = %f\n", float(euclidean_angle_sum))));
|
2022-12-08 18:38:06 +00:00
|
|
|
|
2020-05-31 14:18:44 +00:00
|
|
|
bool infake = fake::in();
|
|
|
|
|
2018-08-19 21:06:32 +00:00
|
|
|
dynamicval<eGeometry> dv(geometry, gArchimedean);
|
2018-08-17 11:29:00 +00:00
|
|
|
|
|
|
|
/* compute the geometry */
|
2020-01-18 15:03:32 +00:00
|
|
|
inradius.resize(N+1); inradius[N] = 0;
|
2021-02-04 14:46:45 +00:00
|
|
|
circumradius.resize(N+1); circumradius[N] = 0;
|
2018-08-17 11:29:00 +00:00
|
|
|
alphas.resize(N);
|
2018-08-21 02:24:14 +00:00
|
|
|
|
2020-05-31 14:18:44 +00:00
|
|
|
ld total = M_PI;
|
|
|
|
|
|
|
|
dynamicval<geometryinfo1> dgi(ginf[geometry].g, ginf[geometry].g);
|
|
|
|
|
|
|
|
if(infake) {
|
|
|
|
total *= N / fake::around;
|
|
|
|
ginf[geometry].g = get_geometry(fake::around / N);
|
|
|
|
}
|
|
|
|
|
2021-08-05 10:21:39 +00:00
|
|
|
ld elmin = 0, elmax = hyperbolic ? 10 : sphere ? M_PI : 2 * euclidean_edge_length;
|
|
|
|
|
2020-01-18 15:03:32 +00:00
|
|
|
/* inradius[N] is used in farcorner and nearcorner. Probably a bug */
|
|
|
|
|
2018-08-21 02:24:14 +00:00
|
|
|
if(real_faces == 2) {
|
2018-08-21 02:55:02 +00:00
|
|
|
/* standard methods fail for dihedra, but the answer is easy */
|
2022-11-12 21:38:45 +00:00
|
|
|
edgelength = TAU / faces[0];
|
2018-08-21 02:24:14 +00:00
|
|
|
for(int i=0; i<N; i++)
|
|
|
|
if(faces[i] == 2)
|
|
|
|
alphas[i] = 0,
|
2018-08-21 15:55:17 +00:00
|
|
|
circumradius[i] = M_PI / real_face_type,
|
2018-08-21 02:24:14 +00:00
|
|
|
inradius[i] = 0;
|
|
|
|
else
|
2022-11-12 21:38:45 +00:00
|
|
|
alphas[i] = 90._deg,
|
|
|
|
circumradius[i] = inradius[i] = 90._deg;
|
2018-08-20 17:41:08 +00:00
|
|
|
}
|
2018-08-21 02:55:02 +00:00
|
|
|
else if(real_faces == 0) {
|
|
|
|
// these are called hosohedra
|
|
|
|
edgelength = M_PI;
|
|
|
|
for(int i=0; i<N; i++)
|
|
|
|
alphas[i] = M_PI / N,
|
2022-11-12 21:38:45 +00:00
|
|
|
circumradius[i] = 90._deg,
|
2018-08-21 02:55:02 +00:00
|
|
|
inradius[i] = 0;
|
|
|
|
}
|
2018-08-20 17:41:08 +00:00
|
|
|
else for(int p=0; p<100; p++) {
|
2022-04-21 19:50:40 +00:00
|
|
|
/* unfortunately we cannot just use compute_edgelength because we need to set other values */
|
2018-08-17 11:29:00 +00:00
|
|
|
edgelength = (elmin + elmax) / 2;
|
|
|
|
|
|
|
|
ld alpha_total = 0;
|
|
|
|
|
|
|
|
for(int i=0; i<N; i++) {
|
2020-04-29 13:09:02 +00:00
|
|
|
|
|
|
|
ld gamma = M_PI / faces[i];
|
|
|
|
|
|
|
|
auto& c = circumradius[i];
|
|
|
|
|
|
|
|
c = asin_auto(sin_auto(edgelength/2) / sin(gamma));
|
2022-12-08 18:38:06 +00:00
|
|
|
inradius[i] = hdist0(mid(lxpush0(circumradius[i]), xspinpush0(2*gamma, circumradius[i])));
|
2020-04-29 13:09:02 +00:00
|
|
|
|
2022-12-08 18:38:06 +00:00
|
|
|
hyperpoint h = lxpush(c) * spin(M_PI - 2*gamma) * lxpush0(c);
|
2020-04-29 13:09:02 +00:00
|
|
|
ld a = atan2(h);
|
|
|
|
cyclefix(a, 0);
|
|
|
|
if(a < 0) a = -a;
|
2018-08-22 23:52:29 +00:00
|
|
|
alphas[i] = a;
|
2018-08-17 11:29:00 +00:00
|
|
|
alpha_total += alphas[i];
|
|
|
|
}
|
|
|
|
|
2020-04-29 13:09:02 +00:00
|
|
|
if(debugflags & DF_GEOM)
|
2021-08-04 16:00:09 +00:00
|
|
|
if(p < 10 || p == 99)
|
2020-04-29 13:09:02 +00:00
|
|
|
println(hlog, "edgelength = ", edgelength, " angles = ", alphas, " inradius = ", inradius, " circumradius = ", circumradius);
|
|
|
|
|
|
|
|
if(isnan(alpha_total)) elmax = edgelength;
|
2020-05-31 14:18:44 +00:00
|
|
|
else if(sphere ^ (alpha_total > total)) elmin = edgelength;
|
2018-08-17 11:29:00 +00:00
|
|
|
else elmax = edgelength;
|
|
|
|
if(euclid) break;
|
|
|
|
}
|
|
|
|
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, (format("computed edgelength = %f\n", float(edgelength))));
|
2018-08-17 11:29:00 +00:00
|
|
|
|
|
|
|
triangles.clear();
|
2018-08-20 00:02:45 +00:00
|
|
|
triangles.resize(2*N+2);
|
2018-08-17 11:29:00 +00:00
|
|
|
for(int i=0; i<N; i++) for(int j=0; j<2; j++)
|
|
|
|
for(int k=0; k<faces[i]; k++)
|
2022-11-12 21:38:45 +00:00
|
|
|
triangles[2*i+j].emplace_back(TAU/faces[i], circumradius[i]);
|
2018-08-17 11:29:00 +00:00
|
|
|
|
|
|
|
for(int k=0; k<N; k++) {
|
|
|
|
triangles[2*N].emplace_back(alphas[k], circumradius[k]);
|
|
|
|
triangles[2*N].emplace_back(alphas[(k+1)%N], edgelength);
|
|
|
|
triangles[2*N+1].emplace_back(alphas[N-1-k], edgelength);
|
|
|
|
triangles[2*N+1].emplace_back(alphas[N-1-k], circumradius[N-1-k]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(auto& ts: triangles) {
|
|
|
|
ld total = 0;
|
|
|
|
for(auto& t: ts) tie(t.first, total) = make_pair(total, total + t.first);
|
|
|
|
}
|
|
|
|
|
2019-05-12 23:57:40 +00:00
|
|
|
if(debugflags & DF_GEOM) for(auto& ts: triangles) {
|
|
|
|
DEBB0(DF_GEOM, ("T"));
|
|
|
|
for(auto& t: ts) DEBB0(DF_GEOM, (format(" %f@%f", float(t.first), float(t.second))));
|
|
|
|
DEBB(DF_GEOM, ());
|
|
|
|
}
|
2020-07-03 13:40:26 +00:00
|
|
|
|
|
|
|
regular = true;
|
|
|
|
for(int i: faces) if(i != faces[0]) regular = false;
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 02:55:39 +00:00
|
|
|
ld archimedean_tiling::scale() {
|
2022-11-12 21:38:45 +00:00
|
|
|
if(real_faces == 0 && N == 2) return 90._deg;
|
|
|
|
if(real_faces == 2) return 90._deg;
|
|
|
|
if(real_faces == 0) return TAU / N;
|
2018-08-21 02:55:39 +00:00
|
|
|
return edgelength;
|
|
|
|
}
|
|
|
|
|
2018-08-18 22:25:43 +00:00
|
|
|
map<heptagon*, vector<pair<heptagon*, transmatrix> > > altmap;
|
|
|
|
|
2019-08-09 19:18:13 +00:00
|
|
|
EX map<heptagon*, pair<heptagon*, transmatrix>> archimedean_gmatrix;
|
2018-08-18 22:25:43 +00:00
|
|
|
|
2019-09-05 09:57:38 +00:00
|
|
|
EX hrmap *current_altmap;
|
2018-08-19 16:04:56 +00:00
|
|
|
|
2018-08-21 02:55:02 +00:00
|
|
|
heptagon *build_child(heptspin p, pair<int, int> adj);
|
|
|
|
|
2019-03-08 21:38:44 +00:00
|
|
|
bool skip_digons(heptspin hs, int step);
|
|
|
|
void connect_digons_too(heptspin h1, heptspin h2);
|
|
|
|
void fixup_matrix(transmatrix& T, const transmatrix& X, ld step);
|
|
|
|
void connectHeptagons(heptspin hi, heptspin hs);
|
2020-05-31 14:18:44 +00:00
|
|
|
|
|
|
|
/** @brief should we use gmatrix to compute relative_matrix faster? (not while in fake Archimedean) */
|
|
|
|
EX bool use_gmatrix = true;
|
|
|
|
|
|
|
|
/** @brief like adj, but in pure
|
|
|
|
* not used by arcm itself, but used in fake arcm
|
|
|
|
*/
|
2019-03-08 21:38:44 +00:00
|
|
|
|
2021-08-05 10:48:14 +00:00
|
|
|
EX geometry_information *alt_cgip;
|
|
|
|
|
2021-08-05 11:17:40 +00:00
|
|
|
EX geometry_information *find_alt_cgip() {
|
|
|
|
if(alt_cgip) return alt_cgip;
|
|
|
|
check_cgi();
|
|
|
|
cgi.require_basics();
|
|
|
|
return alt_cgip = cgip;
|
|
|
|
}
|
|
|
|
|
2018-08-19 21:06:32 +00:00
|
|
|
struct hrmap_archimedean : hrmap {
|
2019-11-27 00:01:20 +00:00
|
|
|
map<gp::loc, struct cdata> eucdata;
|
2018-08-19 16:04:56 +00:00
|
|
|
heptagon *origin;
|
2019-11-30 17:47:04 +00:00
|
|
|
heptagon *getOrigin() override { return origin; }
|
2018-08-19 16:04:56 +00:00
|
|
|
|
2018-08-19 21:06:32 +00:00
|
|
|
hrmap_archimedean() {
|
2019-03-08 21:38:44 +00:00
|
|
|
dynamicval<hrmap*> curmap(currentmap, this);
|
2018-08-30 00:11:43 +00:00
|
|
|
int id = DUAL ? current.N * 2 : 0;;
|
|
|
|
int N0 = isize(current.adjacent[id]);
|
2021-07-04 08:36:16 +00:00
|
|
|
origin = init_heptagon(N0);
|
2018-08-19 16:04:56 +00:00
|
|
|
origin->s = hsOrigin;
|
|
|
|
|
2018-08-30 00:11:43 +00:00
|
|
|
parent_index_of(origin) = DUAL ? 1 : 0;
|
|
|
|
id_of(origin) = id;
|
2018-08-30 14:04:28 +00:00
|
|
|
origin->c7 = newCell(N0/DUALMUL, origin);
|
2018-08-19 16:04:56 +00:00
|
|
|
|
|
|
|
heptagon *alt = NULL;
|
|
|
|
|
|
|
|
if(hyperbolic) {
|
2021-08-05 10:48:14 +00:00
|
|
|
dynamicval<eGeometry> g(geometry, gNormal);
|
|
|
|
dynamicval<eVariation> gv(variation, eVariation::pure);
|
2021-08-05 11:17:40 +00:00
|
|
|
dynamicval<geometry_information*> gi(cgip, find_alt_cgip());
|
|
|
|
alt = init_heptagon(S7);
|
|
|
|
alt->s = hsOrigin;
|
|
|
|
alt->alt = alt;
|
|
|
|
current_altmap = newAltMap(alt);
|
2018-08-19 16:04:56 +00:00
|
|
|
}
|
2021-08-05 10:48:14 +00:00
|
|
|
|
2022-12-08 18:38:06 +00:00
|
|
|
transmatrix T = lxpush(.01241) * spin(1.4117) * lxpush(0.1241) * Id;
|
2018-08-19 21:06:32 +00:00
|
|
|
archimedean_gmatrix[origin] = make_pair(alt, T);
|
2018-08-19 16:04:56 +00:00
|
|
|
altmap[alt].emplace_back(origin, T);
|
2018-08-21 02:24:14 +00:00
|
|
|
|
2018-08-30 00:11:43 +00:00
|
|
|
if(current.real_faces == 0 && DUAL) {
|
|
|
|
heptspin hs(origin, 0);
|
|
|
|
heptagon *hnew = build_child(hs, current.get_adj(hs));
|
|
|
|
for(int s=1; s<2*current.N; s++)
|
|
|
|
origin->c.connect(s, hnew, s, false);
|
|
|
|
}
|
|
|
|
else if(current.real_faces == 0) {
|
2019-03-08 21:38:44 +00:00
|
|
|
may_create_step(origin, 0);
|
2018-08-30 00:11:43 +00:00
|
|
|
heptagon *o0 = origin->move(0);
|
2019-03-08 21:38:44 +00:00
|
|
|
may_create_step(origin, 1);
|
2018-08-30 00:11:43 +00:00
|
|
|
heptagon *o1 = origin->move(1);
|
2018-08-21 02:55:02 +00:00
|
|
|
for(int s=1; s<2*current.N; s+=2)
|
2018-08-30 00:11:43 +00:00
|
|
|
o0->c.connect(s, o1, 2*current.N-s, false);
|
2018-08-21 02:55:02 +00:00
|
|
|
for(int s=2; s<2*current.N; s+=2) {
|
2018-08-30 00:11:43 +00:00
|
|
|
heptspin hs(o0, s);
|
2018-08-21 02:55:02 +00:00
|
|
|
heptagon *hnew = build_child(hs, current.get_adj(hs));
|
|
|
|
// no need to specify archimedean_gmatrix and altmap
|
2018-08-30 00:11:43 +00:00
|
|
|
hnew->c.connect(1, heptspin(o1, 2*current.N-s));
|
2018-08-21 02:55:02 +00:00
|
|
|
}
|
2018-08-30 00:11:43 +00:00
|
|
|
o1->c.connect(1, o0, 2*current.N-1, false);
|
2018-08-21 02:55:02 +00:00
|
|
|
}
|
2018-08-30 00:11:43 +00:00
|
|
|
else if(origin->degree() == 2) {
|
2019-03-08 21:38:44 +00:00
|
|
|
may_create_step(origin, 0);
|
|
|
|
may_create_step(origin, 1);
|
2018-08-21 02:24:14 +00:00
|
|
|
origin->move(0)->c.connect(1, origin->move(1), 2*current.N-1, false);
|
|
|
|
origin->move(1)->c.connect(1, origin->move(0), 2*current.N-1, false);
|
|
|
|
}
|
2018-08-19 16:04:56 +00:00
|
|
|
|
2021-07-30 09:49:13 +00:00
|
|
|
auto_compute_range(origin->c7);
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
|
|
|
|
2018-08-19 21:06:32 +00:00
|
|
|
~hrmap_archimedean() {
|
2018-08-19 16:04:56 +00:00
|
|
|
clearfrom(origin);
|
|
|
|
altmap.clear();
|
2018-08-19 21:06:32 +00:00
|
|
|
archimedean_gmatrix.clear();
|
2018-08-19 16:04:56 +00:00
|
|
|
if(current_altmap) {
|
|
|
|
dynamicval<eGeometry> g(geometry, gNormal);
|
2021-08-05 10:48:14 +00:00
|
|
|
dynamicval<eVariation> gv(variation, eVariation::pure);
|
2021-08-05 11:17:40 +00:00
|
|
|
dynamicval<geometry_information*> gi(cgip, find_alt_cgip());
|
2018-08-19 16:04:56 +00:00
|
|
|
delete current_altmap;
|
|
|
|
current_altmap = NULL;
|
|
|
|
}
|
|
|
|
}
|
2019-11-30 17:47:04 +00:00
|
|
|
void verify() override { }
|
2019-03-08 21:38:44 +00:00
|
|
|
|
2019-11-30 17:47:04 +00:00
|
|
|
heptagon *create_step(heptagon *h, int d) override {
|
2019-03-08 21:38:44 +00:00
|
|
|
|
2021-08-05 10:48:48 +00:00
|
|
|
DEBB(DF_GEOM, (heptspin(h,d), " ~ ?"));
|
2020-05-31 14:18:44 +00:00
|
|
|
|
|
|
|
dynamicval<geometryinfo1> gi(ginf[geometry].g, ginf[gArchimedean].g);
|
|
|
|
|
2019-03-08 21:38:44 +00:00
|
|
|
heptspin hi(h, d);
|
|
|
|
|
|
|
|
while(skip_digons(hi, 1)) hi++;
|
|
|
|
|
|
|
|
auto& t1 = current.get_triangle(hi);
|
|
|
|
|
2022-12-08 18:38:06 +00:00
|
|
|
// * spin(-tri[id][pi+i].first) * lxpush(t.second) * pispin * spin(tri[id'][p'+d'].first)
|
2019-03-08 21:38:44 +00:00
|
|
|
|
|
|
|
auto& p1 = archimedean_gmatrix[h];
|
|
|
|
|
|
|
|
heptagon *alt = p1.first;
|
|
|
|
|
2022-12-08 18:38:06 +00:00
|
|
|
transmatrix T = p1.second * spin(-t1.first) * lxpush(t1.second);
|
2019-03-08 21:38:44 +00:00
|
|
|
transmatrix U = Id;
|
|
|
|
|
|
|
|
if(hyperbolic) {
|
2021-08-05 10:48:14 +00:00
|
|
|
dynamicval<eGeometry> g(geometry, gNormal);
|
|
|
|
dynamicval<eVariation> gv(variation, eVariation::pure);
|
2021-08-05 11:17:40 +00:00
|
|
|
dynamicval<geometry_information*> gi(cgip, find_alt_cgip());
|
2019-03-08 21:38:44 +00:00
|
|
|
dynamicval<hrmap*> cm(currentmap, current_altmap);
|
|
|
|
U = T;
|
2019-11-14 15:51:50 +00:00
|
|
|
current_altmap->virtualRebase(alt, T);
|
2020-09-16 03:57:05 +00:00
|
|
|
U = U * iso_inverse(T);
|
2019-03-08 21:38:44 +00:00
|
|
|
}
|
|
|
|
|
2019-11-27 00:01:20 +00:00
|
|
|
if(euclid) {
|
|
|
|
/* hash the rough coordinates as heptagon* alt */
|
|
|
|
size_t s = size_t(T[0][LDIM]+.261) * 124101 + size_t(T[1][LDIM]+.261) * 82143;
|
|
|
|
alt = (heptagon*) s;
|
|
|
|
}
|
2019-03-08 21:38:44 +00:00
|
|
|
|
2022-08-05 17:21:47 +00:00
|
|
|
DEBB(DF_GEOM, ("look for: ", alt, " / ", kz(T * C0)));
|
2019-03-08 21:38:44 +00:00
|
|
|
|
2022-12-08 18:38:06 +00:00
|
|
|
for(auto& p2: altmap[alt]) if(same_point_may_warn(p2.second * tile_center(), T * tile_center())) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, ("cell found: ", p2.first));
|
2019-03-08 21:38:44 +00:00
|
|
|
for(int d2=0; d2<p2.first->degree(); d2++) {
|
|
|
|
heptspin hs(p2.first, d2);
|
|
|
|
auto& t2 = current.get_triangle(p2.first, d2);
|
|
|
|
transmatrix T1 = T * spin(M_PI + t2.first);
|
2022-12-08 18:38:06 +00:00
|
|
|
DEBB(DF_GEOM, ("compare: ", kz(T1 * lxpush0(1)), ":: ", kz(p2.second * lxpush0(1))));
|
|
|
|
if(same_point_may_warn(T1 * lxpush0(1), p2.second * lxpush0(1))) {
|
2019-03-08 21:38:44 +00:00
|
|
|
|
|
|
|
// T1 = p2.second
|
|
|
|
// T * spin(pi+t2.first) == p2.second
|
2022-12-08 18:38:06 +00:00
|
|
|
// p1.second * spinm(-t1.first) * lxpush(t1.second) * spin(pi+t2.first) == p2.second
|
2019-03-08 21:38:44 +00:00
|
|
|
|
|
|
|
// bring p1 and p2 closer, to prevent floating point errors
|
|
|
|
if(hyperbolic) {
|
2022-12-08 18:38:06 +00:00
|
|
|
fixup_matrix(p1.second, U * p2.second * spin(-M_PI - t2.first) * lxpush(-t1.second) * spin(t1.first), 0.25);
|
2019-03-08 21:38:44 +00:00
|
|
|
fixup_matrix(p2.second, T1, 0.25);
|
|
|
|
}
|
|
|
|
|
|
|
|
while(skip_digons(hs, -1)) hs--;
|
|
|
|
connectHeptagons(hi, hs);
|
|
|
|
connect_digons_too(hi, hs);
|
|
|
|
return h->move(d);
|
|
|
|
}
|
|
|
|
}
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, ("but rotation not found"));
|
2019-03-08 21:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto& t2 = current.get_triangle(current.get_adj(hi));
|
|
|
|
transmatrix T1 = T * spin(M_PI + t2.first);
|
|
|
|
fixmatrix(T1);
|
|
|
|
|
|
|
|
heptagon *hnew = build_child(hi, current.get_adj(hi));
|
|
|
|
altmap[alt].emplace_back(hnew, T1);
|
|
|
|
archimedean_gmatrix[hnew] = make_pair(alt, T1);
|
|
|
|
connect_digons_too(hi, heptspin(hnew, 0));
|
|
|
|
|
|
|
|
return hnew;
|
|
|
|
}
|
|
|
|
|
2020-07-27 17:36:19 +00:00
|
|
|
void draw_at(cell *at, const shiftmatrix& where) override {
|
2020-07-27 16:49:04 +00:00
|
|
|
dq::clear_all();
|
2020-07-27 17:36:19 +00:00
|
|
|
dq::enqueue(at->master, where);
|
2019-03-08 21:38:44 +00:00
|
|
|
|
|
|
|
while(!dq::drawqueue.empty()) {
|
|
|
|
auto& p = dq::drawqueue.front();
|
2020-07-27 16:49:04 +00:00
|
|
|
heptagon *h = p.first;
|
|
|
|
shiftmatrix V = p.second;
|
2019-03-08 21:38:44 +00:00
|
|
|
dq::drawqueue.pop();
|
|
|
|
|
|
|
|
int id = id_of(h);
|
|
|
|
int S = isize(current.triangles[id]);
|
|
|
|
|
|
|
|
if(id < 2*current.N ? !DUAL : !PURE) {
|
|
|
|
if(!do_draw(h->c7, V)) continue;
|
2019-10-25 10:44:41 +00:00
|
|
|
drawcell(h->c7, V);
|
2019-03-08 21:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<S; i++) {
|
|
|
|
if(DUAL && (i&1)) continue;
|
|
|
|
h->cmove(i);
|
|
|
|
if(PURE && id >= 2*current.N && h->move(i) && id_of(h->move(i)) >= 2*current.N) continue;
|
2020-07-27 16:49:04 +00:00
|
|
|
shiftmatrix V1 = V * current.adjcell_matrix(h, i);
|
|
|
|
optimize_shift(V1);
|
2019-03-08 21:38:44 +00:00
|
|
|
dq::enqueue(h->move(i), V1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-28 22:59:16 +00:00
|
|
|
|
|
|
|
transmatrix adj(cell *c, int dir) override {
|
|
|
|
return calc_relative_matrix(c->cmove(dir), c, C0);
|
|
|
|
}
|
2019-03-08 21:38:44 +00:00
|
|
|
|
2021-07-12 13:20:04 +00:00
|
|
|
transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
|
2020-05-31 14:18:44 +00:00
|
|
|
if(use_gmatrix && gmatrix0.count(h2->c7) && gmatrix0.count(h1->c7))
|
2020-07-27 16:49:04 +00:00
|
|
|
return inverse_shift(gmatrix0[h1->c7], gmatrix0[h2->c7]);
|
2019-03-08 21:38:44 +00:00
|
|
|
transmatrix gm = Id, where = Id;
|
2020-05-31 14:18:44 +00:00
|
|
|
auto& cof = current_or_fake();
|
2019-03-08 21:38:44 +00:00
|
|
|
while(h1 != h2) {
|
|
|
|
for(int i=0; i<neighbors_of(h1); i++) {
|
|
|
|
if(h1->move(i) == h2) {
|
2020-05-31 14:18:44 +00:00
|
|
|
return gm * cof.adjcell_matrix(h1, i) * where;
|
2019-03-08 21:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(h1->distance > h2->distance) {
|
2020-05-31 14:18:44 +00:00
|
|
|
gm = gm * cof.adjcell_matrix(h1, 0);
|
2019-03-08 21:38:44 +00:00
|
|
|
h1 = h1->move(0);
|
|
|
|
}
|
|
|
|
else {
|
2020-09-16 03:57:05 +00:00
|
|
|
where = iso_inverse(cof.adjcell_matrix(h2, 0)) * where;
|
2019-03-08 21:38:44 +00:00
|
|
|
h2 = h2->move(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gm * where;
|
|
|
|
}
|
2019-11-14 15:51:50 +00:00
|
|
|
|
2019-11-30 17:47:04 +00:00
|
|
|
ld spin_angle(cell *c, int d) override {
|
2020-05-31 14:18:44 +00:00
|
|
|
auto &cof = current_or_fake();
|
2019-11-14 15:51:50 +00:00
|
|
|
if(PURE) {
|
2020-05-31 14:18:44 +00:00
|
|
|
auto& t1 = cof.get_triangle(c->master, d-1);
|
2019-11-14 15:51:50 +00:00
|
|
|
return -(t1.first + M_PI / c->type);
|
|
|
|
}
|
|
|
|
else if(DUAL) {
|
2020-05-31 14:18:44 +00:00
|
|
|
auto& t1 = cof.get_triangle(c->master, 2*d);
|
2019-11-14 15:51:50 +00:00
|
|
|
return -t1.first;
|
|
|
|
}
|
|
|
|
else { /* BITRUNCATED */
|
2020-05-31 14:18:44 +00:00
|
|
|
auto& t1 = cof.get_triangle(c->master, d);
|
2019-11-14 15:51:50 +00:00
|
|
|
return -t1.first;
|
|
|
|
}
|
|
|
|
}
|
2021-06-12 21:25:59 +00:00
|
|
|
|
|
|
|
void find_cell_connection(cell *c, int d) override {
|
|
|
|
if(PURE) {
|
|
|
|
if(arcm::id_of(c->master) < arcm::current.N * 2) {
|
|
|
|
heptspin hs = heptspin(c->master, d) + wstep + 2 + wstep + 1;
|
|
|
|
c->c.connect(d, hs.at->c7, hs.spin, hs.mirrored);
|
|
|
|
}
|
|
|
|
else c->c.connect(d, c, d, false);
|
|
|
|
}
|
|
|
|
else if(DUAL) {
|
|
|
|
if(arcm::id_of(c->master) >= arcm::current.N * 2) {
|
|
|
|
heptagon *h2 = createStep(c->master, d*2);
|
|
|
|
int d1 = c->master->c.spin(d*2);
|
|
|
|
c->c.connect(d, h2->c7, d1/2, false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("bad connection\n");
|
|
|
|
c->c.connect(d,c,d,false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else hrmap::find_cell_connection(c, d);
|
|
|
|
}
|
2021-06-12 21:34:50 +00:00
|
|
|
|
|
|
|
int shvid(cell *c) override {
|
|
|
|
auto& ac = arcm::current;
|
|
|
|
int id = arcm::id_of(c->master);
|
|
|
|
if(ac.regular && id>=2 && id < 2*ac.N) id &= 1;
|
|
|
|
return id;
|
|
|
|
}
|
2021-06-14 07:38:05 +00:00
|
|
|
|
2021-07-09 08:09:31 +00:00
|
|
|
int full_shvid(cell *c) override {
|
|
|
|
return id_of(c->master) + 20 * parent_index_of(c->master);
|
|
|
|
}
|
|
|
|
|
2021-06-14 07:38:05 +00:00
|
|
|
hyperpoint get_corner(cell *c, int cid, ld cf) override {
|
|
|
|
auto &ac = arcm::current_or_fake();
|
|
|
|
if(PURE) {
|
|
|
|
if(arcm::id_of(c->master) >= ac.N*2) return C0;
|
|
|
|
auto& t = ac.get_triangle(c->master, cid-1);
|
|
|
|
return xspinpush0(-t.first, t.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1));
|
|
|
|
}
|
|
|
|
if(BITRUNCATED) {
|
|
|
|
auto& t0 = ac.get_triangle(c->master, cid-1);
|
|
|
|
auto& t1 = ac.get_triangle(c->master, cid);
|
|
|
|
hyperpoint h0 = xspinpush0(-t0.first, t0.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1));
|
|
|
|
hyperpoint h1 = xspinpush0(-t1.first, t1.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1));
|
2022-12-08 18:38:06 +00:00
|
|
|
return mid3(tile_center(), h0, h1);
|
2021-06-14 07:38:05 +00:00
|
|
|
}
|
|
|
|
if(DUAL) {
|
|
|
|
auto& t0 = ac.get_triangle(c->master, 2*cid-1);
|
|
|
|
return xspinpush0(-t0.first, t0.second * 3 / cf * (ac.real_faces == 0 ? 0.999 : 1));
|
|
|
|
}
|
|
|
|
return C0;
|
|
|
|
}
|
|
|
|
|
2018-08-18 22:25:43 +00:00
|
|
|
};
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX hrmap *new_map() { return new hrmap_archimedean; }
|
2018-08-19 16:04:56 +00:00
|
|
|
|
2018-08-21 02:24:14 +00:00
|
|
|
heptagon *build_child(heptspin p, pair<int, int> adj) {
|
2018-08-17 11:29:00 +00:00
|
|
|
indenter ind;
|
2019-05-05 15:34:46 +00:00
|
|
|
auto h = buildHeptagon1(tailored_alloc<heptagon> (isize(current.adjacent[adj.first])), p.at, p.spin, hstate(1), 0);
|
2021-08-05 10:48:48 +00:00
|
|
|
DEBB(DF_GEOM, ("NEW ", p, " ~ ", heptspin(h, 0)));
|
2018-08-21 02:24:14 +00:00
|
|
|
id_of(h) = adj.first;
|
|
|
|
parent_index_of(h) = adj.second;
|
2018-08-17 11:29:00 +00:00
|
|
|
int nei = neighbors_of(h);
|
2018-08-30 14:04:28 +00:00
|
|
|
h->c7 = newCell(nei/DUALMUL, h);
|
2018-08-21 02:24:14 +00:00
|
|
|
h->distance = p.at->distance + 1;
|
2018-08-30 00:11:43 +00:00
|
|
|
if(adj.first < 2*current.N && !DUAL) {
|
2018-08-21 14:50:53 +00:00
|
|
|
int s = 0;
|
|
|
|
heptspin hs(p);
|
|
|
|
while(id_of(hs.at->move(0)) >= 2 * current.N) {
|
|
|
|
s += hs.spin / 2 - 1;
|
|
|
|
hs = hs - hs.spin + wstep - 1;
|
|
|
|
}
|
|
|
|
h->fieldval = hs.at->move(0)->fieldval + s + hs.spin/2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
h->fieldval = -100;
|
2018-08-20 13:24:44 +00:00
|
|
|
h->fiftyval = isize(archimedean_gmatrix);
|
2018-08-29 02:28:34 +00:00
|
|
|
if(p.at->s == hsOrigin)
|
|
|
|
h->rval1 = 1 + (p.spin % 2);
|
|
|
|
else {
|
|
|
|
if(p.spin % 2 == 0)
|
|
|
|
h->rval1 = p.at->move(0)->rval1;
|
|
|
|
else
|
|
|
|
h->rval1 = 3 - p.at->move(0)->rval1 - p.at->rval1;
|
|
|
|
}
|
2018-08-30 14:02:35 +00:00
|
|
|
h->rval0 = hrand(256);
|
2018-08-21 02:24:14 +00:00
|
|
|
heptspin hs(h, 0);
|
2018-08-17 11:29:00 +00:00
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
2018-08-21 02:24:14 +00:00
|
|
|
bool skip_digons(heptspin hs, int step) {
|
|
|
|
return
|
|
|
|
isize(current.adjacent[current.get_adj(hs).first]) == 2 ||
|
|
|
|
isize(current.adjacent[current.get_adj(hs+step).first]) == 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void connect_digons_too(heptspin h1, heptspin h2) {
|
|
|
|
if(skip_digons(h1, -1)) {
|
|
|
|
h1--, h2++;
|
|
|
|
heptagon *hnew = build_child(h1, current.get_adj(h1));
|
|
|
|
// no need to specify archimedean_gmatrix and altmap
|
|
|
|
hnew->c.connect(1, h2);
|
|
|
|
h1--, h2++;
|
2020-02-23 02:48:46 +00:00
|
|
|
DEBB(DF_GEOM, (format("OL2 %p.%d ~ %p.%d\n", hr::voidp(h1.at), h1.spin, hr::voidp(h2.at), h2.spin)));
|
2018-08-21 02:24:14 +00:00
|
|
|
h1.at->c.connect(h1.spin, h2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void connectHeptagons(heptspin hi, heptspin hs) {
|
2021-08-05 10:48:48 +00:00
|
|
|
DEBB(DF_GEOM, ("OLD ", hi, " ~ ", hs));
|
2018-08-21 02:24:14 +00:00
|
|
|
if(hi.at->move(hi.spin) == hs.at && hi.at->c.spin(hi.spin) == hs.spin) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, (format("WARNING: already connected\n")));
|
2018-08-17 11:29:00 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-08-21 02:24:14 +00:00
|
|
|
if(hi.peek()) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, (format("ERROR: already connected left\n")));
|
2021-07-04 07:32:29 +00:00
|
|
|
throw hr_archimedean_error("Archimedean error: already connected left");
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
2018-08-17 22:46:45 +00:00
|
|
|
if(hs.peek()) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM, (format("ERROR: already connected right\n")));
|
2021-07-04 07:32:29 +00:00
|
|
|
throw hr_archimedean_error("Archimedean error: already connected right");
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
2018-08-21 02:24:14 +00:00
|
|
|
hi.at->c.connect(hi.spin, hs);
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2018-08-21 02:24:14 +00:00
|
|
|
auto p = current.get_adj(hi);
|
2018-08-21 15:54:53 +00:00
|
|
|
if(current.tilegroup[p.first] != current.tilegroup[id_of(hs.at)]) {
|
2018-08-19 11:47:51 +00:00
|
|
|
printf("should merge %d %d\n", p.first, id_of(hs.at));
|
2018-08-21 15:54:53 +00:00
|
|
|
current.make_match(p.first, p.second, id_of(hs.at), hs.spin + parent_index_of(hs.at));
|
|
|
|
current.regroup();
|
|
|
|
}
|
2018-08-19 11:47:51 +00:00
|
|
|
// heptagon *hnew = build_child(h, d, get_adj(h, d).first, get_adj(h, d).second);
|
|
|
|
}
|
2018-08-18 15:46:02 +00:00
|
|
|
|
2019-08-10 11:43:24 +00:00
|
|
|
/** T and X are supposed to be equal -- move T so that it is closer to X */
|
2018-11-10 10:51:47 +00:00
|
|
|
void fixup_matrix(transmatrix& T, const transmatrix& X, ld step) {
|
2020-11-01 16:37:51 +00:00
|
|
|
for(int i=0; i<MXDIM; i++)
|
|
|
|
for(int j=0; j<MXDIM; j++)
|
2018-11-10 10:51:47 +00:00
|
|
|
T[i][j] = (T[i][j] * (1-step) + X[i][j] * step);
|
|
|
|
|
|
|
|
/*
|
|
|
|
for(int i=0; i<3; i++)
|
|
|
|
for(int j=0; j<3; j++)
|
|
|
|
if(T[i][j] - X[i][j] > 1e-3) exit(1);
|
|
|
|
*/
|
|
|
|
fixmatrix(T);
|
|
|
|
}
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
pair<ld, ld>& archimedean_tiling::get_triangle(heptagon *h, int cid) {
|
2020-01-18 15:03:32 +00:00
|
|
|
return triangles[id_of(h)][gmod(parent_index_of(h) + cid, neighbors_of(h))];
|
2018-08-18 15:46:02 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
pair<int, int>& archimedean_tiling::get_adj(heptagon *h, int cid) {
|
2020-01-18 15:03:32 +00:00
|
|
|
return adjacent[id_of(h)][gmod(parent_index_of(h) + cid, neighbors_of(h))];
|
2018-08-18 15:46:02 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
pair<int, int>& archimedean_tiling::get_adj(const pair<int, int>& p, int delta) {
|
2020-01-18 15:03:32 +00:00
|
|
|
return adjacent[p.first][gmod(p.second + delta, isize(adjacent[p.first]))];
|
2018-08-18 15:46:02 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
pair<ld, ld>& archimedean_tiling::get_triangle(const pair<int, int>& p, int delta) {
|
2020-01-18 15:03:32 +00:00
|
|
|
return triangles[p.first][gmod(p.second + delta, isize(adjacent[p.first]))];
|
2018-08-18 22:25:43 +00:00
|
|
|
}
|
|
|
|
|
2020-05-31 14:18:44 +00:00
|
|
|
transmatrix archimedean_tiling::adjcell_matrix(heptagon *h, int d) {
|
|
|
|
auto& t1 = get_triangle(h, d);
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
heptagon *h2 = h->move(d);
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2018-08-17 22:46:45 +00:00
|
|
|
int d2 = h->c.spin(d);
|
2020-05-31 14:18:44 +00:00
|
|
|
auto& t2 = get_triangle(h2, d2);
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2022-12-08 18:38:06 +00:00
|
|
|
return spin(-t1.first) * lxpush(t1.second) * spin(M_PI + t2.first);
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:18:13 +00:00
|
|
|
EX int fix(heptagon *h, int spin) {
|
2018-08-20 00:02:45 +00:00
|
|
|
int type = isize(current.adjacent[id_of(h)]);
|
2018-08-17 11:29:00 +00:00
|
|
|
spin %= type;
|
|
|
|
if(spin < 0) spin += type;
|
|
|
|
return spin;
|
|
|
|
}
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
void archimedean_tiling::parse() {
|
2018-08-17 11:29:00 +00:00
|
|
|
int at = 0;
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
auto peek = [&] () { if(at == isize(symbol)) return char(0); else return symbol[at]; };
|
2018-09-23 00:27:19 +00:00
|
|
|
auto is_number = [&] () { char p = peek(); return p >= '0' && p <= '9'; };
|
|
|
|
auto read_number = [&] () { int result = 0; while(is_number()) result = 10 * result + peek() - '0', at++; return result; };
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2018-08-19 11:47:51 +00:00
|
|
|
faces.clear(); nflags.clear();
|
|
|
|
have_line = false;
|
|
|
|
have_ph = false;
|
2020-01-28 09:29:36 +00:00
|
|
|
int nflags0 = 0;
|
2018-08-30 14:06:51 +00:00
|
|
|
auto nfback = [this, &nflags0] () -> int& { if(nflags.empty()) return nflags0; else return nflags.back(); };
|
2018-08-17 11:29:00 +00:00
|
|
|
while(true) {
|
2018-08-21 22:01:38 +00:00
|
|
|
if(peek() == ')' || (peek() == '(' && isize(faces)) || peek() == 0) break;
|
|
|
|
else if((peek() == 'L') && faces.size()) {
|
2018-08-30 14:06:51 +00:00
|
|
|
if(!nflags.empty()) nfback() |= sfLINE;
|
2018-08-21 22:01:38 +00:00
|
|
|
have_line = true, at++;
|
|
|
|
}
|
|
|
|
else if((peek() == 'l') && faces.size()) {
|
2018-08-30 14:06:51 +00:00
|
|
|
if(!nflags.empty()) nfback() |= sfSEMILINE;
|
2018-08-21 22:01:38 +00:00
|
|
|
have_line = true, at++;
|
|
|
|
}
|
|
|
|
else if((peek() == 'H' || peek() == 'h') && faces.size()) {
|
2018-08-30 14:06:51 +00:00
|
|
|
if(!nflags.empty()) nfback() |= sfPH;
|
2018-08-21 22:01:38 +00:00
|
|
|
have_ph = true, at++;
|
|
|
|
}
|
2018-09-23 00:27:19 +00:00
|
|
|
else if(is_number()) faces.push_back(read_number()), nflags.push_back(0);
|
2018-08-21 22:01:38 +00:00
|
|
|
else if(peek() == '^' && !faces.empty()) {
|
|
|
|
at++;
|
|
|
|
int rep = read_number();
|
|
|
|
if(rep == 0) nflags.pop_back(), faces.pop_back();
|
2018-08-30 14:06:51 +00:00
|
|
|
for(int i=1; i<rep; i++) nflags.push_back(nfback()), faces.push_back(faces.back());
|
2018-08-21 22:01:38 +00:00
|
|
|
}
|
2018-08-17 11:29:00 +00:00
|
|
|
else at++;
|
|
|
|
}
|
2018-08-30 14:06:51 +00:00
|
|
|
nflags.push_back(nflags0);
|
2018-08-17 11:29:00 +00:00
|
|
|
repetition = 1;
|
|
|
|
N = isize(faces);
|
2018-08-18 15:46:02 +00:00
|
|
|
invert.clear(); invert.resize(N, true);
|
2018-08-17 11:29:00 +00:00
|
|
|
adj.clear(); adj.resize(N, 0); for(int i=0; i<N; i++) adj[i] = i;
|
|
|
|
while(peek() != 0) {
|
|
|
|
if(peek() == '^') at++, repetition = read_number();
|
|
|
|
else if(peek() == '(') {
|
2018-09-23 00:27:19 +00:00
|
|
|
at++; int a = read_number(); while(!is_number() && !among(peek(), '(', '[', ')',']', 0)) at++;
|
|
|
|
if(is_number()) { int b = read_number(); adj[a] = b; adj[b] = a; invert[a] = invert[b] = false; }
|
2018-08-18 15:46:02 +00:00
|
|
|
else { invert[a] = false; }
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
|
|
|
else if(peek() == '[') {
|
2018-09-23 00:27:19 +00:00
|
|
|
at++; int a = read_number(); while(!is_number() && !among(peek(), '(', '[', ')',']', 0)) at++;
|
|
|
|
if(is_number()) { int b = read_number(); adj[a] = b; adj[b] = a; invert[a] = invert[b] = true; }
|
2018-08-17 11:29:00 +00:00
|
|
|
else { invert[a] = true; }
|
|
|
|
}
|
|
|
|
else at++;
|
|
|
|
}
|
2018-08-21 22:01:38 +00:00
|
|
|
for(int i=0; i<N * (repetition-1); i++)
|
|
|
|
faces.push_back(faces[i]),
|
|
|
|
nflags.push_back(nflags[i]),
|
|
|
|
invert.push_back(invert[i]),
|
|
|
|
adj.push_back(adj[i] + N);
|
|
|
|
N *= repetition;
|
2018-08-17 11:29:00 +00:00
|
|
|
prepare();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CAP_COMMANDLINE
|
|
|
|
int readArgs() {
|
|
|
|
using namespace arg;
|
|
|
|
|
|
|
|
if(0) ;
|
|
|
|
else if(argis("-symbol")) {
|
2018-08-30 15:54:23 +00:00
|
|
|
PHASEFROM(2);
|
2018-08-20 00:02:45 +00:00
|
|
|
archimedean_tiling at;
|
|
|
|
shift(); at.parse(args());
|
|
|
|
if(at.errors) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_ERROR | DF_GEOM, ("error: ", at.errormsg));
|
2018-08-20 00:02:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-08-28 15:17:34 +00:00
|
|
|
set_geometry(gArchimedean);
|
2018-08-20 00:02:45 +00:00
|
|
|
current = at;
|
|
|
|
showstartmenu = false;
|
|
|
|
}
|
2018-08-17 11:29:00 +00:00
|
|
|
}
|
2018-08-30 15:54:23 +00:00
|
|
|
else if(argis("-dual")) { PHASEFROM(2); set_variation(eVariation::dual); }
|
2018-11-11 10:06:32 +00:00
|
|
|
else if(argis("-d:arcm"))
|
|
|
|
launch_dialog(show);
|
2018-08-17 11:29:00 +00:00
|
|
|
else return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CAP_COMMANDLINE
|
|
|
|
auto hook =
|
2019-05-30 14:12:38 +00:00
|
|
|
addHook(hooks_args, 100, readArgs)
|
|
|
|
+ addHook(hooks_gamedata, 0, [] (gamedata* gd) { gd->store(altmap); gd->store(archimedean_gmatrix); gd->store(current_altmap); });
|
|
|
|
|
2018-08-17 11:29:00 +00:00
|
|
|
#endif
|
|
|
|
|
2019-05-08 19:09:22 +00:00
|
|
|
#if MAXMDIM >= 4
|
|
|
|
auto hooksw = addHook(hooks_swapdim, 100, [] {
|
2021-08-05 11:17:40 +00:00
|
|
|
|
|
|
|
dynamicval<eGeometry> g(geometry, gNormal);
|
|
|
|
dynamicval<eVariation> gv(variation, eVariation::pure);
|
|
|
|
dynamicval<geometry_information*> gi(cgip, find_alt_cgip());
|
|
|
|
|
2019-05-08 19:09:22 +00:00
|
|
|
for(auto& p: altmap) for(auto& pp: p.second) swapmatrix(pp.second);
|
|
|
|
for(auto& p: archimedean_gmatrix) swapmatrix(p.second.second);
|
2021-08-05 11:17:40 +00:00
|
|
|
|
|
|
|
alt_cgip = nullptr;
|
2019-05-08 19:09:22 +00:00
|
|
|
});
|
|
|
|
#endif
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
int archimedean_tiling::support_threecolor() {
|
2018-08-20 13:24:44 +00:00
|
|
|
return (isize(faces) == 3 && invert[0] && invert[1] && invert[2] && faces[0] % 2 == 0 && faces[1] % 2 == 0 && faces[2] % 2 == 0) ? 2 :
|
|
|
|
tilegroup[N*2] > 1 ? 1 :
|
|
|
|
0;
|
2018-08-19 11:47:51 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2018-08-29 02:28:34 +00:00
|
|
|
int archimedean_tiling::support_threecolor_bitruncated() {
|
2018-08-30 14:44:17 +00:00
|
|
|
for(int i: faces) if(i % 2) return 0;
|
2018-08-30 00:11:43 +00:00
|
|
|
return 2;
|
2018-08-29 02:28:34 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 13:24:44 +00:00
|
|
|
int archimedean_tiling::support_football() {
|
2018-08-19 11:47:51 +00:00
|
|
|
return
|
2018-08-20 00:02:45 +00:00
|
|
|
have_ph ? 1 :
|
2018-08-20 13:24:44 +00:00
|
|
|
(isize(faces) == 3 && invert[0] && invert[1] && invert[2] && faces[1] % 2 == 0 && faces[2] % 2 == 0) ? 2 :
|
2018-08-19 11:47:51 +00:00
|
|
|
0;
|
|
|
|
}
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
bool archimedean_tiling::support_chessboard() {
|
2018-08-20 09:59:43 +00:00
|
|
|
return N % 2 == 0;
|
2018-08-19 13:15:47 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool pseudohept(cell *c) {
|
2018-08-30 14:02:35 +00:00
|
|
|
if(DUAL)
|
|
|
|
return !(c->master->rval0 & 3);
|
|
|
|
int id = id_of(c->master);
|
2018-08-29 02:28:34 +00:00
|
|
|
if(PURE)
|
|
|
|
return current.flags[id] & arcm::sfPH;
|
|
|
|
if(BITRUNCATED)
|
|
|
|
return id < current.N * 2;
|
|
|
|
return false;
|
2018-08-19 11:47:51 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool chessvalue(cell *c) {
|
2018-08-30 00:11:43 +00:00
|
|
|
if(DUAL)
|
|
|
|
return c->master->rval1 - 1;
|
2018-08-20 09:59:43 +00:00
|
|
|
return c->master->fieldval & 1;
|
2018-08-19 16:06:54 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool linespattern(cell *c) {
|
2018-08-20 00:02:45 +00:00
|
|
|
return current.flags[id_of(c->master)] & arcm::sfLINE;
|
2018-08-19 11:47:51 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int threecolor(cell *c) {
|
2018-08-22 09:52:11 +00:00
|
|
|
if(current.have_ph)
|
2018-08-30 14:02:35 +00:00
|
|
|
return !arcm::pseudohept(c);
|
2018-08-28 15:17:34 +00:00
|
|
|
else if(PURE)
|
2018-08-30 14:02:35 +00:00
|
|
|
return current.tilegroup[id_of(c->master)];
|
2018-08-19 11:47:51 +00:00
|
|
|
else {
|
2018-08-30 14:02:35 +00:00
|
|
|
int id = id_of(c->master);
|
2018-08-20 00:02:45 +00:00
|
|
|
if(current.support_threecolor() == 2) return id < current.N * 2 ? (id&1) : 2;
|
|
|
|
return current.tilegroup[id];
|
2018-08-19 11:47:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-21 14:10:01 +00:00
|
|
|
int cEucRegular = 0x008000;
|
|
|
|
int cEucSemiregular = 0x40C040;
|
|
|
|
int cPlatonic = 0x000080;
|
|
|
|
int cArchimedean = 0x4040C0;
|
|
|
|
int cPrism = 0x40A0A0;
|
|
|
|
int cAntiPrism = 0x80A0A0;
|
|
|
|
int cHyperRegular = 0x800000;
|
|
|
|
int cHyperSemi = 0xC04040;
|
|
|
|
|
|
|
|
int cWeird = 0xA000A0;
|
|
|
|
|
2020-03-29 10:00:33 +00:00
|
|
|
EX vector<pair<string, int> > samples = {
|
2018-08-19 20:53:34 +00:00
|
|
|
/* Euclidean */
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,3,3,3,3,3)", cEucRegular},
|
|
|
|
{"(4,4,4,4)", cEucRegular},
|
|
|
|
{"(6,6,6)", cEucRegular},
|
|
|
|
{"(8,8,4)", cEucSemiregular},
|
|
|
|
{"(4,6,12)", cEucSemiregular},
|
|
|
|
{"(6,4,3,4)", cEucSemiregular},
|
|
|
|
{"(3,6,3,6)", cEucSemiregular},
|
|
|
|
{"(3,12,12)", cEucSemiregular},
|
2018-08-22 23:53:04 +00:00
|
|
|
{"(4,4,3L,3L,3L) [3,4]", cEucSemiregular},
|
|
|
|
{"(3,3,3,3,6) (1,2)(0,4)(3)", cEucSemiregular},
|
|
|
|
{"(3,3,4,3,4) (0,4)(1)(2,3)", cEucSemiregular},
|
2018-08-19 20:53:34 +00:00
|
|
|
|
|
|
|
/* Platonic */
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,3,3)", cPlatonic},
|
|
|
|
{"(3,3,3,3)", cPlatonic},
|
|
|
|
{"(3,3,3,3,3)", cPlatonic},
|
|
|
|
{"(4,4,4)", cPlatonic},
|
|
|
|
{"(5,5,5)", cPlatonic},
|
2018-08-19 20:53:34 +00:00
|
|
|
|
|
|
|
/* Archimedean solids */
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,6,6)", cArchimedean},
|
|
|
|
{"(3,4,3,4)", cArchimedean},
|
|
|
|
{"(3,8,8)", cArchimedean},
|
|
|
|
{"(4,6,6)", cArchimedean},
|
|
|
|
{"(3,4,4,4)", cArchimedean},
|
|
|
|
{"(4,6,8)", cArchimedean},
|
2018-08-22 23:53:04 +00:00
|
|
|
{"(3,3,3,3,4) (1,2)(0,4)(3)", cArchimedean},
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,5,3,5)", cArchimedean},
|
|
|
|
{"(3,10,10)", cArchimedean},
|
|
|
|
{"(5,6,6)", cArchimedean},
|
|
|
|
{"(3,4,5,4)", cArchimedean},
|
|
|
|
{"(4,6,10)", cArchimedean},
|
2018-08-22 23:53:04 +00:00
|
|
|
{"(3,3,3,3,5) (1,2)(0,4)(3)", cArchimedean},
|
2018-08-19 20:53:34 +00:00
|
|
|
|
|
|
|
/* prisms */
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,4,4)", cPrism},
|
|
|
|
{"(5,4,4)", cPrism},
|
|
|
|
{"(6,4,4)", cPrism},
|
|
|
|
{"(7,4,4)", cPrism},
|
2018-08-19 20:53:34 +00:00
|
|
|
|
|
|
|
/* sample antiprisms */
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,3,3,4)(1)(2)", cAntiPrism},
|
|
|
|
{"(3,3,3,5)(1)(2)", cAntiPrism},
|
|
|
|
{"(3,3,3,6)(1)(2)", cAntiPrism},
|
|
|
|
{"(3,3,3,7)(1)(2)", cAntiPrism},
|
2018-08-19 20:53:34 +00:00
|
|
|
|
|
|
|
/* hyperbolic ones */
|
2018-08-21 22:01:38 +00:00
|
|
|
{"(3)^7", cHyperRegular},
|
|
|
|
{"(4)^5", cHyperRegular},
|
|
|
|
{"(4)^6", cHyperRegular},
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(5,5,5,5)", cHyperRegular},
|
|
|
|
{"(7,7,7)", cHyperRegular},
|
|
|
|
{"(8,8,8)", cHyperRegular},
|
2018-08-21 22:01:38 +00:00
|
|
|
{"(7,6^2)", cHyperSemi},
|
|
|
|
{"(4,6,14)", cHyperSemi},
|
|
|
|
{"(3,4,7,4)", cHyperSemi},
|
2018-08-22 23:53:04 +00:00
|
|
|
{"(6,6,4L,4L)", cHyperSemi},
|
|
|
|
{"(8,8,4L,4L)", cHyperSemi},
|
|
|
|
{"(3,3,3,3,7) (1,2)(0,4)(3)", cHyperSemi},
|
|
|
|
{"(3H,6,6,6) (1,0)[2](3)", cHyperSemi},
|
2018-08-24 21:43:21 +00:00
|
|
|
{"(3,6,6,6) (0 1)(2)(3)", cHyperSemi},
|
2018-08-21 15:54:53 +00:00
|
|
|
{"(3,4,4L,4L,4)", cHyperSemi}, // buggy
|
|
|
|
{"(3l,4l,4,4,4) (0 1)[2 3](4)", cHyperSemi},
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,4,4,4,4) (0 1)(2)(3)(4)", cHyperSemi},
|
2018-08-21 15:54:53 +00:00
|
|
|
{"(3,4,4L,4L,4L,4)", cHyperSemi},
|
|
|
|
{"(6,6,3L,3L,3L) (0 2)(1)(3)(4)", cHyperSemi},
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(5,3,5,3,3) (0 1)(2 3)(4)", cHyperSemi},
|
|
|
|
{"(4,3,3,3,3,3) (0 1)(2 3)(4 5)", cHyperSemi},
|
2018-08-21 15:54:53 +00:00
|
|
|
{"(3l,5l,5,5,5,5) (0 1)[2 3](4)(5)", cHyperSemi},
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,5,5,5,5,5) (0 1)(2 4)(3 5)", cHyperSemi},
|
2018-08-21 15:54:53 +00:00
|
|
|
{"(3l,5l,5,5,5,5) (0 1)(2 4)[3 5]", cHyperSemi},
|
|
|
|
{"(3l,5l,5,5,5,5) (0 1)[2 4](3)(5)", cHyperSemi},
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(3,5,5,5,5,5) (0 1)(2)(3)(4)(5)", cHyperSemi},
|
2020-03-29 10:00:33 +00:00
|
|
|
{"(3,3,4,3,5)(0,4)(1)(2,3)", cHyperSemi},
|
|
|
|
{"(3,14,14)", cHyperSemi},
|
|
|
|
{"(3,3,3,3,3,4)[0](1,2)(3,4)[5]", cHyperSemi},
|
2018-08-21 02:24:14 +00:00
|
|
|
|
2018-08-21 22:01:38 +00:00
|
|
|
/* interesting symmetry variants */
|
2018-08-22 23:53:04 +00:00
|
|
|
{"(3,3,3,3,3,3) (0,1)(2,3)(4,5)", cEucRegular},
|
2018-08-30 14:09:43 +00:00
|
|
|
{"(3,3H,3,3,3L,3L,3L) (0 4)(1 2)(3)(5)(6)", cHyperRegular},
|
|
|
|
{"(3,3H,3,3,3L,3L,3L) (0 4)(1 2)(3)[5 6]", cHyperRegular},
|
|
|
|
{"(3,3H,3,3L,3,3L,3L) [0 4](1 2)[3 5](6)", cHyperRegular},
|
2018-08-21 22:01:38 +00:00
|
|
|
|
2018-08-21 02:24:14 +00:00
|
|
|
/* with digons */
|
2018-08-22 23:53:04 +00:00
|
|
|
{"(2,3,3,3,3,3) (2,3)(4,5)", cWeird},
|
2018-08-21 14:10:01 +00:00
|
|
|
{"(6,6)", cWeird},
|
|
|
|
{"(2,2)", cWeird},
|
2018-08-21 15:54:53 +00:00
|
|
|
{"(2,2,2,2,2,2)", cWeird},
|
|
|
|
{"(6,6,2)", cWeird},
|
2018-08-21 17:00:29 +00:00
|
|
|
{"(6,2,6,2)", cWeird},
|
2018-08-19 20:53:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int lastsample = 0;
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
vector<archimedean_tiling> tilings;
|
2018-08-19 20:53:34 +00:00
|
|
|
|
|
|
|
int spos = 0;
|
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
archimedean_tiling edited;
|
2018-08-19 20:53:34 +00:00
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
bool symbol_editing;
|
|
|
|
|
2019-09-06 06:17:02 +00:00
|
|
|
EX void next_variation() {
|
2018-08-30 00:11:43 +00:00
|
|
|
set_variation(
|
|
|
|
PURE ? eVariation::dual :
|
|
|
|
DUAL ? eVariation::bitruncated :
|
|
|
|
eVariation::pure);
|
|
|
|
start_game();
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void enable(archimedean_tiling& arct) {
|
2018-08-19 21:06:32 +00:00
|
|
|
stop_game();
|
2019-12-14 10:42:16 +00:00
|
|
|
if(!in()) set_variation(eVariation::pure);
|
2018-08-28 15:17:34 +00:00
|
|
|
set_geometry(gArchimedean);
|
2018-08-28 02:05:32 +00:00
|
|
|
patterns::whichPattern = patterns::PAT_NONE;
|
2018-08-30 15:54:04 +00:00
|
|
|
current = arct;
|
2018-08-21 22:14:31 +00:00
|
|
|
#if CAP_TEXTURE
|
2018-08-30 15:54:04 +00:00
|
|
|
if(texture::config.tstate == texture::tsActive && texture::cgroup == cpThree) {
|
2018-08-20 13:24:44 +00:00
|
|
|
patterns::whichPattern = patterns::PAT_COLORING;
|
2018-08-30 15:54:04 +00:00
|
|
|
if(geosupport_threecolor() < 2) {
|
|
|
|
if(arct.support_threecolor() == 2) set_variation(eVariation::pure);
|
|
|
|
else if(arct.support_threecolor_bitruncated() == 2) set_variation(eVariation::bitruncated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(texture::config.tstate == texture::tsActive && texture::cgroup == cpFootball) {
|
2018-08-28 02:05:32 +00:00
|
|
|
patterns::whichPattern = patterns::PAT_TYPES, patterns::subpattern_flags = patterns::SPF_FOOTBALL;
|
2018-08-30 15:54:04 +00:00
|
|
|
if(geosupport_football() < 2) set_variation(eVariation::bitruncated);
|
|
|
|
}
|
|
|
|
if(texture::config.tstate == texture::tsActive && texture::cgroup == cpChess) {
|
2018-08-20 13:24:44 +00:00
|
|
|
patterns::whichPattern = patterns::PAT_CHESS;
|
2018-08-30 15:54:04 +00:00
|
|
|
if(!geosupport_chessboard()) {
|
|
|
|
if(arct.support_chessboard()) set_variation(eVariation::pure);
|
|
|
|
else if(arct.support_threecolor_bitruncated() == 2) set_variation(eVariation::dual);
|
|
|
|
}
|
|
|
|
}
|
2018-08-21 22:14:31 +00:00
|
|
|
#endif
|
2018-08-19 21:06:32 +00:00
|
|
|
start_game();
|
|
|
|
}
|
|
|
|
|
2018-08-31 18:49:44 +00:00
|
|
|
function<void()> setcanvas(char c) {
|
|
|
|
return [c] () {
|
|
|
|
stop_game();
|
2021-04-23 18:09:23 +00:00
|
|
|
enable_canvas();
|
2018-08-31 18:49:44 +00:00
|
|
|
patterns::whichCanvas = c;
|
|
|
|
start_game();
|
|
|
|
};
|
2020-02-23 01:51:27 +00:00
|
|
|
}
|
2018-08-31 18:49:44 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void show() {
|
2018-08-20 00:02:45 +00:00
|
|
|
if(lastsample < isize(samples)) {
|
2018-08-21 14:10:01 +00:00
|
|
|
string s = samples[lastsample].first;
|
|
|
|
int col = samples[lastsample].second;
|
|
|
|
lastsample++;
|
2018-08-20 00:02:45 +00:00
|
|
|
archimedean_tiling tested;
|
|
|
|
tested.parse(s);
|
|
|
|
if(tested.errors) {
|
2019-05-12 23:57:40 +00:00
|
|
|
DEBB(DF_GEOM | DF_WARN, ("WARNING: ", tested.errors, " errors on ", s, " '", tested.errormsg, "'"));
|
2018-08-19 20:53:34 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-08-21 14:10:01 +00:00
|
|
|
tested.coloring = col;
|
2022-07-05 17:23:05 +00:00
|
|
|
tilings.push_back(std::move(tested));
|
2018-08-21 14:10:01 +00:00
|
|
|
/* sort(tilings.begin(), tilings.end(), [] (archimedean_tiling& s1, archimedean_tiling& s2) {
|
2018-08-20 00:02:45 +00:00
|
|
|
if(s1.euclidean_angle_sum < s2.euclidean_angle_sum - 1e-6) return true;
|
|
|
|
if(s2.euclidean_angle_sum < s1.euclidean_angle_sum - 1e-6) return false;
|
|
|
|
return s1.symbol < s2.symbol;
|
2018-08-21 14:10:01 +00:00
|
|
|
}); */
|
2018-08-19 20:53:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cmode = sm::SIDE | sm::MAYDARK;
|
2022-07-05 09:51:06 +00:00
|
|
|
gamescreen();
|
2018-08-19 20:53:34 +00:00
|
|
|
dialog::init(XLAT("Archimedean tilings"));
|
2018-08-20 00:02:45 +00:00
|
|
|
|
|
|
|
if(symbol_editing) {
|
2018-11-06 23:50:03 +00:00
|
|
|
dialog::addSelItem("edit", dialog::view_edited_string(), '/');
|
2018-08-20 00:02:45 +00:00
|
|
|
dialog::add_action([] () {
|
|
|
|
symbol_editing = false;
|
|
|
|
if(!edited.errors) enable(edited);
|
|
|
|
});
|
|
|
|
dialog::addBreak(100);
|
|
|
|
if(edited.errors)
|
|
|
|
dialog::addInfo(edited.errormsg, 0xFF0000);
|
|
|
|
else
|
|
|
|
dialog::addInfo(XLAT("OK"), 0x00FF00);
|
2018-08-20 13:24:44 +00:00
|
|
|
|
2018-08-20 00:02:45 +00:00
|
|
|
dialog::addBreak(100);
|
|
|
|
dialog::addSelItem(XLAT("full angle"), fts(edited.euclidean_angle_sum * 180) + "°", 0);
|
2018-08-22 23:52:29 +00:00
|
|
|
dialog::addSelItem(XLAT("size of the world"), edited.world_size(), 0);
|
|
|
|
|
|
|
|
edited.compute_geometry();
|
|
|
|
dialog::addSelItem(XLAT("edge length"), fts(edited.edgelength) + (edited.get_class() == gcEuclid ? XLAT(" (arbitrary)") : ""), 0);
|
|
|
|
current.compute_geometry();
|
2019-07-03 05:31:09 +00:00
|
|
|
|
|
|
|
dialog::addBreak(100);
|
|
|
|
dialog::addKeyboardItem("1234567890");
|
|
|
|
dialog::addKeyboardItem("()[]lLhH,");
|
|
|
|
dialog::addKeyboardItem(" \t\b\x1\x2\n");
|
2018-08-20 00:02:45 +00:00
|
|
|
dialog::addBreak(100);
|
|
|
|
}
|
|
|
|
else {
|
2019-12-14 10:42:16 +00:00
|
|
|
string cs = in() ? current.symbol : XLAT("OFF");
|
2018-08-20 00:02:45 +00:00
|
|
|
dialog::addSelItem("edit", cs, '/');
|
|
|
|
dialog::add_action([] () {
|
|
|
|
symbol_editing = true;
|
|
|
|
edited = current;
|
2018-11-06 23:50:03 +00:00
|
|
|
dialog::start_editing(edited.symbol);
|
2018-08-20 00:02:45 +00:00
|
|
|
edited.parse();
|
|
|
|
});
|
2018-08-19 20:53:34 +00:00
|
|
|
dialog::addBreak(100);
|
2018-08-20 13:24:44 +00:00
|
|
|
int nextpos = spos;
|
|
|
|
int shown = 0;
|
|
|
|
while(nextpos < isize(tilings) && shown < 10) {
|
|
|
|
auto &ps = tilings[nextpos++];
|
2018-08-30 15:54:04 +00:00
|
|
|
bool valid = true;
|
|
|
|
string suffix = "";
|
2018-08-21 22:14:31 +00:00
|
|
|
#if CAP_TEXTURE
|
2018-08-30 15:54:04 +00:00
|
|
|
if(texture::config.tstate == texture::tsActive && texture::cgroup == cpThree) {
|
|
|
|
valid = false;
|
|
|
|
if(ps.support_threecolor() == 2) valid = true, suffix += bitruncnames[int(eVariation::pure)];
|
|
|
|
if(ps.support_threecolor_bitruncated() == 2) valid = true, suffix += bitruncnames[int(eVariation::bitruncated)];
|
|
|
|
}
|
|
|
|
if(texture::config.tstate == texture::tsActive && texture::cgroup == cpFootball) {
|
|
|
|
if(ps.support_football() == 2) suffix += bitruncnames[int(eVariation::pure)];
|
|
|
|
suffix += bitruncnames[int(eVariation::bitruncated)];
|
|
|
|
}
|
|
|
|
if(texture::config.tstate == texture::tsActive && texture::cgroup == cpChess && !ps.support_chessboard()) {
|
|
|
|
valid = false;
|
|
|
|
if(ps.support_chessboard()) valid = true, suffix += bitruncnames[int(eVariation::pure)];
|
|
|
|
if(ps.support_threecolor_bitruncated() == 2) valid = true, suffix += bitruncnames[int(eVariation::dual)];
|
|
|
|
}
|
2018-08-21 22:14:31 +00:00
|
|
|
#endif
|
2018-08-30 15:54:04 +00:00
|
|
|
if(!valid) continue;
|
2019-11-24 22:39:45 +00:00
|
|
|
if(current_filter == &gf_hyperbolic && ps.get_geometry().kind != gcHyperbolic) continue;
|
|
|
|
if(current_filter == &gf_spherical && ps.get_geometry().kind != gcSphere) continue;
|
|
|
|
if(current_filter == &gf_euclidean && ps.get_geometry().kind != gcEuclid) continue;
|
2018-08-30 15:54:04 +00:00
|
|
|
dialog::addSelItem(ps.symbol, fts(ps.euclidean_angle_sum * 180) + "°" + suffix, 'a' + shown);
|
2018-08-21 14:10:01 +00:00
|
|
|
dialog::lastItem().color = ps.coloring;
|
2018-08-20 00:02:45 +00:00
|
|
|
dialog::add_action([&] () { enable(ps); });
|
2018-08-20 13:24:44 +00:00
|
|
|
shown++;
|
2018-08-19 20:53:34 +00:00
|
|
|
}
|
2019-11-24 22:39:45 +00:00
|
|
|
dialog::addSelItem(XLAT("current filter"), current_filter ? XLAT(current_filter->name) : XLAT("none"), 'x');
|
|
|
|
dialog::add_action([] {
|
|
|
|
if(current_filter == &gf_hyperbolic) current_filter = &gf_euclidean;
|
|
|
|
else if(current_filter == &gf_euclidean) current_filter = &gf_spherical;
|
|
|
|
else if(current_filter == &gf_spherical) current_filter = nullptr;
|
|
|
|
else current_filter = &gf_hyperbolic;
|
|
|
|
});
|
2018-08-19 20:53:34 +00:00
|
|
|
dialog::addItem(XLAT("next page"), '-');
|
2018-08-20 13:24:44 +00:00
|
|
|
if(shown == 0) nextpos = 0;
|
|
|
|
dialog::add_action([nextpos] () {
|
|
|
|
if(nextpos >= isize(tilings))
|
2018-08-19 20:53:34 +00:00
|
|
|
spos = 0;
|
2018-08-20 13:24:44 +00:00
|
|
|
else spos = nextpos;
|
2018-08-19 20:53:34 +00:00
|
|
|
});
|
2018-08-24 21:52:02 +00:00
|
|
|
dialog::addItem(XLAT("previous page"), '=');
|
|
|
|
dialog::add_action([] () {
|
|
|
|
spos -= 10;
|
|
|
|
if(spos < 0) spos = 0;
|
|
|
|
});
|
2018-08-20 00:50:51 +00:00
|
|
|
|
2019-12-14 10:42:16 +00:00
|
|
|
if(in()) {
|
2018-08-22 23:52:29 +00:00
|
|
|
dialog::addSelItem(XLAT("size of the world"), current.world_size(), 0);
|
2019-05-21 22:01:30 +00:00
|
|
|
dialog::addSelItem(XLAT("edge length"), current.get_class() == gcEuclid ? (fts(current.edgelength) + XLAT(" (arbitrary)")) : fts(current.edgelength), 0);
|
2018-08-22 23:52:29 +00:00
|
|
|
|
2018-08-20 13:49:17 +00:00
|
|
|
dialog::addItem(XLAT("color by symmetries"), 't');
|
2018-08-30 14:44:17 +00:00
|
|
|
dialog::add_action(setcanvas('A'));
|
2022-10-06 11:35:56 +00:00
|
|
|
dialog::addItem(XLAT("color by symmetries (reversed tiles marked)"), 'r');
|
|
|
|
dialog::add_action(setcanvas('R'));
|
2018-08-30 14:44:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
dialog::addBreak(100);
|
|
|
|
dialog::addBreak(100);
|
|
|
|
dialog::addBreak(100);
|
2018-08-20 00:50:51 +00:00
|
|
|
}
|
2018-08-20 13:49:17 +00:00
|
|
|
|
|
|
|
if(true) {
|
|
|
|
dialog::addItem(XLAT("color by sides"), 'u');
|
2018-08-30 14:44:17 +00:00
|
|
|
dialog::add_action(setcanvas('B'));
|
2018-08-20 13:49:17 +00:00
|
|
|
}
|
2018-08-30 14:44:17 +00:00
|
|
|
|
|
|
|
if(geosupport_threecolor() == 2) {
|
|
|
|
dialog::addItem(XLAT("three colors"), 'w');
|
|
|
|
dialog::add_action(setcanvas('T'));
|
|
|
|
}
|
|
|
|
else if(geosupport_football() == 2) {
|
|
|
|
dialog::addItem(XLAT("football"), 'w');
|
|
|
|
dialog::add_action(setcanvas('F'));
|
|
|
|
}
|
|
|
|
else if(geosupport_chessboard()) {
|
|
|
|
dialog::addItem(XLAT("chessboard"), 'w');
|
|
|
|
dialog::add_action(setcanvas('c'));
|
|
|
|
}
|
|
|
|
else dialog::addBreak(100);
|
2018-08-29 02:28:34 +00:00
|
|
|
|
2019-12-14 10:42:16 +00:00
|
|
|
if(in()) {
|
2018-08-29 02:28:34 +00:00
|
|
|
dialog::addSelItem(XLAT("variations"), gp::operation_name(), 'v');
|
2018-08-30 00:11:43 +00:00
|
|
|
dialog::add_action(next_variation);
|
2018-08-29 02:28:34 +00:00
|
|
|
}
|
2018-08-30 14:44:17 +00:00
|
|
|
else dialog::addBreak(100);
|
2018-08-19 20:53:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dialog::addHelp();
|
|
|
|
dialog::addBack();
|
|
|
|
dialog::display();
|
2018-08-17 11:29:00 +00:00
|
|
|
|
2018-08-19 20:53:34 +00:00
|
|
|
keyhandler = [] (int sym, int uni) {
|
2018-08-20 00:02:45 +00:00
|
|
|
if(symbol_editing && sym == SDLK_RETURN) sym = uni = '/';
|
2018-08-19 20:53:34 +00:00
|
|
|
dialog::handleNavigation(sym, uni);
|
2018-11-06 23:50:03 +00:00
|
|
|
if(symbol_editing && dialog::handle_edit_string(sym, uni)) {
|
2018-08-20 00:02:45 +00:00
|
|
|
edited.parse(edited.symbol);
|
2018-08-19 20:53:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(doexiton(sym, uni)) popScreen();
|
|
|
|
};
|
|
|
|
}
|
2018-08-21 17:00:29 +00:00
|
|
|
|
2019-08-26 13:38:20 +00:00
|
|
|
void archimedean_tiling::get_nom_denom(int& anom, int& adenom) {
|
2018-08-21 17:00:29 +00:00
|
|
|
int nom = 2 - N, denom = 2;
|
|
|
|
for(int f: faces) {
|
2022-03-27 18:44:45 +00:00
|
|
|
if(f == 0) {
|
|
|
|
/* prevent a crash */
|
|
|
|
anom = 1; adenom = 1; return;
|
|
|
|
}
|
2018-08-21 17:00:29 +00:00
|
|
|
int g = gcd(denom, f);
|
|
|
|
nom = (nom * f + denom) / g;
|
|
|
|
denom = denom / g * f;
|
|
|
|
}
|
2019-08-26 13:38:20 +00:00
|
|
|
anom = 0, adenom = 1;
|
2018-08-30 00:11:43 +00:00
|
|
|
if(BITRUNCATED || DUAL) anom = 1, adenom = 1;
|
|
|
|
if(!DUAL) for(int f: faces) {
|
2018-08-21 17:00:29 +00:00
|
|
|
int g = gcd(adenom, f);
|
|
|
|
anom = (anom * f + adenom) / g;
|
|
|
|
adenom = adenom / g * f;
|
|
|
|
}
|
|
|
|
anom *= 2 * denom, adenom *= nom;
|
|
|
|
int g = gcd(anom, adenom);
|
2018-12-06 12:01:23 +00:00
|
|
|
if(g != 0) {
|
|
|
|
anom /= g; adenom /= g;
|
|
|
|
}
|
2018-08-21 17:00:29 +00:00
|
|
|
if(adenom < 0) anom = -anom, adenom = -adenom;
|
2019-08-26 13:38:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string archimedean_tiling::world_size() {
|
|
|
|
if(get_class() == gcEuclid) return "∞";
|
|
|
|
|
|
|
|
int anom, adenom;
|
|
|
|
get_nom_denom(anom, adenom);
|
|
|
|
|
2018-08-21 17:00:29 +00:00
|
|
|
string s;
|
2018-08-22 23:52:29 +00:00
|
|
|
bool hyp = (anom < 0);
|
|
|
|
if(hyp) anom = -anom;
|
2018-12-06 12:01:23 +00:00
|
|
|
if(adenom != 1)
|
2018-08-21 17:00:29 +00:00
|
|
|
s += its(anom) + "/" + its(adenom);
|
|
|
|
else
|
|
|
|
s += its(anom);
|
2018-08-22 23:52:29 +00:00
|
|
|
if(hyp) s += " exp(∞)";
|
2018-08-21 17:00:29 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int degree(heptagon *h) {
|
2018-08-30 00:11:43 +00:00
|
|
|
return isize(current.adjacent[id_of(h)]);
|
|
|
|
}
|
2018-08-30 14:05:24 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX bool is_vertex(heptagon *h) {
|
2018-08-30 14:05:52 +00:00
|
|
|
return id_of(h) >= 2 * current.N;
|
|
|
|
}
|
|
|
|
|
2019-08-27 16:59:26 +00:00
|
|
|
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; }
|
2019-08-27 19:57:25 +00:00
|
|
|
int g = gcd(denom, f);
|
|
|
|
nom = nom * (f/g) + (f-2) * (denom/g);
|
|
|
|
denom = denom/g * f;
|
2019-08-27 16:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
steps = 2 * abs(denom);
|
|
|
|
single_step = abs(nom);
|
|
|
|
if(steps/2 != abs(denom)) return false;
|
|
|
|
return (2 * denom) % nom == 0;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX int valence() {
|
2018-08-30 14:05:24 +00:00
|
|
|
if(PURE) return arcm::current.N;
|
|
|
|
if(BITRUNCATED) return 3;
|
|
|
|
// in DUAL, usually valence would depend on the vertex.
|
|
|
|
// 3 is the most interesting, as it allows us to kill hedgehog warriors
|
|
|
|
int total = 0;
|
|
|
|
for(int i: current.faces) {
|
|
|
|
if(i == 3) return 3;
|
|
|
|
total += i;
|
|
|
|
}
|
|
|
|
return total / isize(current.faces);
|
|
|
|
}
|
2018-08-30 00:11:43 +00:00
|
|
|
|
2019-11-27 00:01:20 +00:00
|
|
|
EX map<gp::loc, cdata>& get_cdata() { return ((arcm::hrmap_archimedean*) (currentmap))->eucdata; }
|
2019-12-14 10:42:16 +00:00
|
|
|
|
2020-10-15 14:33:52 +00:00
|
|
|
#endif
|
|
|
|
|
2019-12-14 10:42:16 +00:00
|
|
|
EX }
|
2018-08-19 20:53:34 +00:00
|
|
|
|
|
|
|
}
|