1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-06-07 17:04:06 +00:00

archimedean::get_nom_denom factored out

This commit is contained in:
Zeno Rogue 2019-08-26 15:38:20 +02:00
parent 0311210576
commit 7bd80dab18

View File

@ -68,6 +68,7 @@ struct archimedean_tiling {
bool support_chessboard(); bool support_chessboard();
void regroup(); void regroup();
string world_size(); string world_size();
void get_nom_denom(int& anom, int& adenom);
geometryinfo1& get_geometry(); geometryinfo1& get_geometry();
eGeometryClass get_class() { return get_geometry().kind; } eGeometryClass get_class() { return get_geometry().kind; }
@ -1253,16 +1254,14 @@ EX void show() {
}; };
} }
string archimedean_tiling::world_size() { void archimedean_tiling::get_nom_denom(int& anom, int& adenom) {
if(get_class() == gcEuclid) return "";
int nom = 2 - N, denom = 2; int nom = 2 - N, denom = 2;
for(int f: faces) { for(int f: faces) {
int g = gcd(denom, f); int g = gcd(denom, f);
nom = (nom * f + denom) / g; nom = (nom * f + denom) / g;
denom = denom / g * f; denom = denom / g * f;
} }
int anom = 0, adenom = 1; anom = 0, adenom = 1;
if(BITRUNCATED || DUAL) anom = 1, adenom = 1; if(BITRUNCATED || DUAL) anom = 1, adenom = 1;
if(!DUAL) for(int f: faces) { if(!DUAL) for(int f: faces) {
int g = gcd(adenom, f); int g = gcd(adenom, f);
@ -1275,6 +1274,14 @@ string archimedean_tiling::world_size() {
anom /= g; adenom /= g; anom /= g; adenom /= g;
} }
if(adenom < 0) anom = -anom, adenom = -adenom; if(adenom < 0) anom = -anom, adenom = -adenom;
}
string archimedean_tiling::world_size() {
if(get_class() == gcEuclid) return "";
int anom, adenom;
get_nom_denom(anom, adenom);
string s; string s;
bool hyp = (anom < 0); bool hyp = (anom < 0);
if(hyp) anom = -anom; if(hyp) anom = -anom;