1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-05-16 14:14:07 +00:00

renamed as_gp and as_coord to to_loc and to_coord

This commit is contained in:
Zeno Rogue 2019-11-29 17:21:58 +01:00
parent 16eb050788
commit 638f408d05
4 changed files with 29 additions and 29 deletions

View File

@ -526,8 +526,8 @@ EX namespace euclid3 {
} }
else { else {
twisted &= 8; twisted &= 8;
twisted_vec = as_gp(T0[1]); twisted_vec = to_loc(T0[1]);
ortho_vec = as_gp(T0[0]); ortho_vec = to_loc(T0[0]);
if(twisted_vec == gp::loc{0,0}) twisted = 0; if(twisted_vec == gp::loc{0,0}) twisted = 0;
if(chiral(twisted_vec)) twisted = 0; if(chiral(twisted_vec)) twisted = 0;
if(dscalar(twisted_vec, ortho_vec)) if(dscalar(twisted_vec, ortho_vec))
@ -614,11 +614,11 @@ EX namespace euclid3 {
return coo; return coo;
} }
else { else {
gp::loc coo = as_gp(x); gp::loc coo = to_loc(x);
gp::loc ort = ort1() * twisted_vec; gp::loc ort = ort1() * twisted_vec;
int dsc = dscalar(twisted_vec, twisted_vec); int dsc = dscalar(twisted_vec, twisted_vec);
gp::loc d0 (d[0], d[1]); gp::loc d0 (d[0], d[1]);
hyperpoint h = eumove(as_coord(twisted_vec)) * C0; hyperpoint h = eumove(to_coord(twisted_vec)) * C0;
while(true) { while(true) {
int dsx = dscalar(coo, twisted_vec); int dsx = dscalar(coo, twisted_vec);
if(dsx >= dsc) coo = coo - twisted_vec; if(dsx >= dsc) coo = coo - twisted_vec;
@ -646,7 +646,7 @@ EX namespace euclid3 {
} }
} }
d[0] = d0.first; d[1] = d0.second; d[0] = d0.first; d[1] = d0.second;
return as_coord(coo); return to_coord(coo);
} }
} }
@ -807,9 +807,9 @@ EX namespace euclid3 {
else { else {
if(T_edit[1][0] == 0 && T_edit[1][1] == 0) if(T_edit[1][0] == 0 && T_edit[1][1] == 0)
dialog::addInfo(XLAT("change the second column for Möbius bands and Klein bottles")); dialog::addInfo(XLAT("change the second column for Möbius bands and Klein bottles"));
else if(chiral(as_gp(T_edit[1]))) else if(chiral(to_loc(T_edit[1])))
dialog::addInfo(XLAT("second period is chiral -- cannot be mirrored")); dialog::addInfo(XLAT("second period is chiral -- cannot be mirrored"));
else if(dscalar(as_gp(T_edit[1]), as_gp(T_edit[0]))) else if(dscalar(to_loc(T_edit[1]), to_loc(T_edit[0])))
dialog::addInfo(XLAT("periods must be orthogonal for mirroring")); dialog::addInfo(XLAT("periods must be orthogonal for mirroring"));
else { else {
dialog::addBoolItem(XLAT("mirror flip in the second period"), twisted_edit & 8, 'x'); dialog::addBoolItem(XLAT("mirror flip in the second period"), twisted_edit & 8, 'x');
@ -975,14 +975,14 @@ EX int dcross(gp::loc e1, gp::loc e2) {
EX gp::loc euc2_coordinates(cell *c) { EX gp::loc euc2_coordinates(cell *c) {
auto ans = euclid3::eucmap()->ispacemap[c->master]; auto ans = euclid3::eucmap()->ispacemap[c->master];
if(BITRUNCATED) if(BITRUNCATED)
return as_gp(ans) * gp::loc(1,1) + (c == c->master->c7 ? gp::loc(0,0) : gp::eudir((c->c.spin(0)+4)%6)); return to_loc(ans) * gp::loc(1,1) + (c == c->master->c7 ? gp::loc(0,0) : gp::eudir((c->c.spin(0)+4)%6));
if(GOLDBERG) { if(GOLDBERG) {
auto li = gp::get_local_info(c); auto li = gp::get_local_info(c);
gp::loc shift(0,0); gp::loc shift(0,0);
if(li.first_dir >= 0) shift = gp::eudir(li.last_dir) * li.relative; if(li.first_dir >= 0) shift = gp::eudir(li.last_dir) * li.relative;
return as_gp(ans) * gp::param + shift; return to_loc(ans) * gp::param + shift;
} }
return as_gp(ans); return to_loc(ans);
} }
/** this is slow, but we use it only for small p's */ /** this is slow, but we use it only for small p's */
@ -994,9 +994,9 @@ EX cell* at_euc2_coordinates(gp::loc p) {
return cw.at; return cw.at;
} }
EX euclid3::coord as_coord(gp::loc p) { return euclid3::coord(p.first, p.second, 0); } EX euclid3::coord to_coord(gp::loc p) { return euclid3::coord(p.first, p.second, 0); }
EX gp::loc sdxy() { return as_gp(euclid3::T[1]) * gp::univ_param(); } EX gp::loc sdxy() { return to_loc(euclid3::T[1]) * gp::univ_param(); }
EX pair<bool, string> coord_display(const transmatrix& V, cell *c) { EX pair<bool, string> coord_display(const transmatrix& V, cell *c) {
if(c != c->master->c7) return {false, ""}; if(c != c->master->c7) return {false, ""};
@ -1011,7 +1011,7 @@ EX pair<bool, string> coord_display(const transmatrix& V, cell *c) {
return {true, fts(h[0]) + "," + fts(h[1]) }; return {true, fts(h[0]) + "," + fts(h[1]) };
} }
EX gp::loc as_gp(const euclid3::coord& v) { return gp::loc(v[0], v[1]); } EX gp::loc to_loc(const euclid3::coord& v) { return gp::loc(v[0], v[1]); }
EX map<gp::loc, cdata>& get_cdata() { return euclid3::eucmap()->eucdata; } EX map<gp::loc, cdata>& get_cdata() { return euclid3::eucmap()->eucdata; }
@ -1071,8 +1071,8 @@ EX int eudist(gp::loc a, gp::loc b) {
} }
EX int cyldist(gp::loc a, gp::loc b) { EX int cyldist(gp::loc a, gp::loc b) {
a = as_gp(euclid3::canonicalize(as_coord(a))); a = to_loc(euclid3::canonicalize(to_coord(a)));
b = as_gp(euclid3::canonicalize(as_coord(b))); b = to_loc(euclid3::canonicalize(to_coord(b)));
if(!quotient) return eudist(a, b); if(!quotient) return eudist(a, b);

View File

@ -192,7 +192,7 @@ EX namespace models {
if(euclid) { if(euclid) {
euclidean_spin = pispin * inverse(cview() * master_relative(centerover, true)); euclidean_spin = pispin * inverse(cview() * master_relative(centerover, true));
euclidean_spin = gpushxto0(euclidean_spin * C0) * euclidean_spin; euclidean_spin = gpushxto0(euclidean_spin * C0) * euclidean_spin;
hyperpoint h = inverse(euclidean_spin) * (C0 + (eumove(as_coord({1,0}))*C0 - C0) * spiral_x + (eumove(as_coord({0,1}))*C0 - C0) * spiral_y); hyperpoint h = inverse(euclidean_spin) * (C0 + (eumove(to_coord({1,0}))*C0 - C0) * spiral_x + (eumove(to_coord({0,1}))*C0 - C0) * spiral_y);
spiral_multiplier = cld(0, 2 * M_PI) / cld(h[0], h[1]); spiral_multiplier = cld(0, 2 * M_PI) / cld(h[0], h[1]);
} }
@ -267,13 +267,13 @@ EX namespace models {
for(int y=0; y<=200; y++) for(int y=0; y<=200; y++)
for(int x=-200; x<=200; x++) { for(int x=-200; x<=200; x++) {
if(y == 0 && x <= 0) continue; if(y == 0 && x <= 0) continue;
auto zero = euclid3::canonicalize(as_coord({x, y})); auto zero = euclid3::canonicalize(to_coord({x, y}));
if(zero == euclid3::euzero) if(zero == euclid3::euzero)
torus_zeros.emplace_back(x, y); torus_zeros.emplace_back(x, y);
} }
sort(torus_zeros.begin(), torus_zeros.end(), [] (const gp::loc p1, const gp::loc p2) { sort(torus_zeros.begin(), torus_zeros.end(), [] (const gp::loc p1, const gp::loc p2) {
ld d1 = hdist0(tC0(eumove(as_coord(p1)))); ld d1 = hdist0(tC0(eumove(to_coord(p1))));
ld d2 = hdist0(tC0(eumove(as_coord(p2)))); ld d2 = hdist0(tC0(eumove(to_coord(p2))));
if(d1 < d2 - 1e-6) return true; if(d1 < d2 - 1e-6) return true;
if(d1 > d2 + 1e-6) return false; if(d1 > d2 + 1e-6) return false;
return p1 < p2; return p1 < p2;

View File

@ -2433,12 +2433,12 @@ EX namespace linepatterns {
case patZebraTriangles: case patZebraTriangles:
if(euclid6) { if(euclid6) {
if(c != c->master->c7 || patterns::sevenval(c)) break; if(c != c->master->c7 || patterns::sevenval(c)) break;
gridline(V, C0, tC0(eumove(as_coord({-1, +3}))), col, 3 + vid.linequality); gridline(V, C0, tC0(eumove(to_coord({-1, +3}))), col, 3 + vid.linequality);
gridline(V, C0, tC0(eumove(as_coord({-3, +2}))), col, 3 + vid.linequality); gridline(V, C0, tC0(eumove(to_coord({-3, +2}))), col, 3 + vid.linequality);
gridline(V, C0, tC0(eumove(as_coord({-2, -1}))), col, 3 + vid.linequality); gridline(V, C0, tC0(eumove(to_coord({-2, -1}))), col, 3 + vid.linequality);
gridline(V, C0, tC0(eumove(as_coord({+1, -3}))), col, 3 + vid.linequality); gridline(V, C0, tC0(eumove(to_coord({+1, -3}))), col, 3 + vid.linequality);
gridline(V, C0, tC0(eumove(as_coord({+3, -2}))), col, 3 + vid.linequality); gridline(V, C0, tC0(eumove(to_coord({+3, -2}))), col, 3 + vid.linequality);
gridline(V, C0, tC0(eumove(as_coord({+2, +1}))), col, 3 + vid.linequality); gridline(V, C0, tC0(eumove(to_coord({+2, +1}))), col, 3 + vid.linequality);
break; break;
} }
if(zebra40(c) / 4 == 10) { if(zebra40(c) / 4 == 10) {

View File

@ -432,11 +432,11 @@ EX void buildTorusRug() {
calcparam_rug(); calcparam_rug();
models::configure(); models::configure();
auto p1 = as_gp(euclid3::T0[0]); auto p1 = to_loc(euclid3::T0[0]);
auto p2 = as_gp(euclid3::T0[1]); auto p2 = to_loc(euclid3::T0[1]);
hyperpoint xh = eumove(as_coord(p1))*C0-C0; hyperpoint xh = eumove(to_coord(p1))*C0-C0;
hyperpoint yh = eumove(as_coord(p2))*C0-C0; hyperpoint yh = eumove(to_coord(p2))*C0-C0;
if(nonorientable) yh *= 2; if(nonorientable) yh *= 2;
bool flipped = sqhypot_d(2, xh) < sqhypot_d(2, yh); bool flipped = sqhypot_d(2, xh) < sqhypot_d(2, yh);