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
1 changed files with 11 additions and 4 deletions

View File

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