1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

Archimedean precise analyzer

This commit is contained in:
Zeno Rogue 2019-08-27 18:59:26 +02:00
parent 142566a5bd
commit f6f37b1e45
3 changed files with 39 additions and 7 deletions

View File

@ -73,6 +73,8 @@ struct archimedean_tiling {
geometryinfo1& get_geometry(); geometryinfo1& get_geometry();
eGeometryClass get_class() { return get_geometry().kind; } eGeometryClass get_class() { return get_geometry().kind; }
bool get_step_values(int& steps, int& single_step);
ld scale(); ld scale();
}; };
#endif #endif
@ -1232,6 +1234,10 @@ EX void show() {
} }
else dialog::addBreak(100); 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) { if(archimedean) {
dialog::addSelItem(XLAT("variations"), gp::operation_name(), 'v'); dialog::addSelItem(XLAT("variations"), gp::operation_name(), 'v');
dialog::add_action(next_variation); dialog::add_action(next_variation);
@ -1301,6 +1307,26 @@ EX bool is_vertex(heptagon *h) {
return id_of(h) >= 2 * current.N; 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() { EX int valence() {
if(PURE) return arcm::current.N; if(PURE) return arcm::current.N;
if(BITRUNCATED) return 3; if(BITRUNCATED) return 3;

View File

@ -444,7 +444,17 @@ void ge_select_tiling(const vector<eGeometry>& lst) {
if(archimedean) ok = PURE; if(archimedean) ok = PURE;
else if(binarytiling || penrose) ok = false; else if(binarytiling || penrose) ok = false;
else ok = PURE || BITRUNCATED; 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); set_geometry(targetgeometry);
start_game(); start_game();

View File

@ -576,12 +576,8 @@ void geometry_information::prepare_basics() {
steps = 0; steps = 0;
single_step = 1; single_step = 1;
if(hybri && !prod) { if(hybri && !prod) {
if(hybrid::underlying == gArchimedean) { if(hybrid::underlying == gArchimedean)
ld s = arcm::current.euclidean_angle_sum - 2; arcm::current.get_step_values(steps, single_step);
single_step = 2;
DEBB(DF_GEOM | DF_POLY, ("1/s = ", 1/s));
steps = 4/abs(s) + .5;
}
else { else {
single_step = S3 * S7 - 2 * S7 - 2 * S3; single_step = S3 * S7 - 2 * S7 - 2 * S3;
steps = 2 * S7; steps = 2 * S7;