mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-04 14:30:35 +00:00
arb:: specify H2 or S2 tilings, extra functions
This commit is contained in:
parent
14a70fe1bf
commit
7f1f5ccb43
@ -43,19 +43,19 @@ EX arbi_tiling current;
|
|||||||
EX short& id_of(heptagon *h) { return h->zebraval; }
|
EX short& id_of(heptagon *h) { return h->zebraval; }
|
||||||
|
|
||||||
void shape::build_from_angles_edges() {
|
void shape::build_from_angles_edges() {
|
||||||
hyperpoint at(0, 0, 1, 0);
|
transmatrix at = Id;
|
||||||
hyperpoint direction(1, 0, 0, 0);
|
|
||||||
vertices.clear();
|
vertices.clear();
|
||||||
int n = isize(angles);
|
int n = isize(angles);
|
||||||
hyperpoint ctr = Hypc;
|
hyperpoint ctr = Hypc;
|
||||||
for(int i=0; i<n; i++) {
|
for(int i=0; i<n; i++) {
|
||||||
vertices.push_back(at);
|
println(hlog, "at = ", at);
|
||||||
ctr += at;
|
vertices.push_back(tC0(at));
|
||||||
at += direction * edges[i];
|
ctr += tC0(at);
|
||||||
direction = spin(angles[i]) * direction;
|
at = at * xpush(edges[i]) * spin(angles[i]);
|
||||||
}
|
}
|
||||||
|
if(!eqmatrix(at, Id)) throw hr_parse_exception("polygon error");
|
||||||
ctr = normalize(ctr);
|
ctr = normalize(ctr);
|
||||||
for(auto& v: vertices) v = v + (C0 - ctr);
|
for(auto& v: vertices) v = gpushxto0(ctr) * v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool correct_index(int index, int size) { return index >= 0 && index < size; }
|
bool correct_index(int index, int size) { return index >= 0 && index < size; }
|
||||||
@ -75,20 +75,31 @@ void load(const string& fname) {
|
|||||||
c.shapes.clear();
|
c.shapes.clear();
|
||||||
exp_parser ep;
|
exp_parser ep;
|
||||||
ep.s = s;
|
ep.s = s;
|
||||||
ld angleunit = 1, distunit = 1;
|
ld angleunit = 1, distunit = 1, angleofs = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
ep.skip_white();
|
ep.skip_white();
|
||||||
if(ep.next() == 0) break;
|
if(ep.next() == 0) break;
|
||||||
if(ep.eat("e2.")) println(hlog, "got e2");
|
if(ep.eat("e2.")) {
|
||||||
if(ep.eat("angleunit(")) angleunit = real(ep.parsepar());
|
ginf[gArbitrary].g = giEuclid2;
|
||||||
if(ep.eat("distunit(")) distunit = real(ep.parsepar());
|
set_flag(ginf[gArbitrary].flags, qBOUNDED, false);
|
||||||
if(ep.eat("let(")) {
|
}
|
||||||
|
else if(ep.eat("h2.")) {
|
||||||
|
ginf[gArbitrary].g = giHyperb2;
|
||||||
|
set_flag(ginf[gArbitrary].flags, qBOUNDED, false);
|
||||||
|
}
|
||||||
|
else if(ep.eat("s2.")) {
|
||||||
|
ginf[gArbitrary].g = giSphere2;
|
||||||
|
set_flag(ginf[gArbitrary].flags, qBOUNDED, false);
|
||||||
|
}
|
||||||
|
else if(ep.eat("angleunit(")) angleunit = real(ep.parsepar());
|
||||||
|
else if(ep.eat("angleofs(")) angleofs = real(ep.parsepar());
|
||||||
|
else if(ep.eat("distunit(")) distunit = real(ep.parsepar());
|
||||||
|
else if(ep.eat("let(")) {
|
||||||
string tok = ep.next_token();
|
string tok = ep.next_token();
|
||||||
ep.force_eat("=");
|
ep.force_eat("=");
|
||||||
ep.extra_params[tok] =ep.parsepar();
|
ep.extra_params[tok] =ep.parsepar();
|
||||||
}
|
}
|
||||||
if(ep.eat("tile(")) {
|
else if(ep.eat("tile(")) {
|
||||||
println(hlog, "reading shape with angleunit = ", angleunit);
|
|
||||||
c.shapes.emplace_back();
|
c.shapes.emplace_back();
|
||||||
auto& cc = c.shapes.back();
|
auto& cc = c.shapes.back();
|
||||||
cc.id = isize(c.shapes) - 1;
|
cc.id = isize(c.shapes) - 1;
|
||||||
@ -97,7 +108,7 @@ void load(const string& fname) {
|
|||||||
ep.force_eat(",");
|
ep.force_eat(",");
|
||||||
ld angle = ep.rparse(0);
|
ld angle = ep.rparse(0);
|
||||||
cc.edges.push_back(dist * distunit);
|
cc.edges.push_back(dist * distunit);
|
||||||
cc.angles.push_back(angle * angleunit);
|
cc.angles.push_back(angle * angleunit + angleofs);
|
||||||
if(ep.eat(",")) continue;
|
if(ep.eat(",")) continue;
|
||||||
else if(ep.eat(")")) break;
|
else if(ep.eat(")")) break;
|
||||||
else throw hr_parse_exception("expecting , or )");
|
else throw hr_parse_exception("expecting , or )");
|
||||||
@ -105,7 +116,7 @@ void load(const string& fname) {
|
|||||||
cc.build_from_angles_edges();
|
cc.build_from_angles_edges();
|
||||||
cc.connections.resize(cc.size());
|
cc.connections.resize(cc.size());
|
||||||
}
|
}
|
||||||
if(ep.eat("c(")) {
|
else if(ep.eat("c(")) {
|
||||||
int ai = ep.iparse(); verify_index(ai, c.shapes); ep.force_eat(",");
|
int ai = ep.iparse(); verify_index(ai, c.shapes); ep.force_eat(",");
|
||||||
int as = ep.iparse(); verify_index(as, c.shapes[ai]); ep.force_eat(",");
|
int as = ep.iparse(); verify_index(as, c.shapes[ai]); ep.force_eat(",");
|
||||||
int bi = ep.iparse(); verify_index(bi, c.shapes); ep.force_eat(",");
|
int bi = ep.iparse(); verify_index(bi, c.shapes); ep.force_eat(",");
|
||||||
@ -149,7 +160,6 @@ struct hrmap_arbi : hrmap {
|
|||||||
|
|
||||||
heptagon *alt = NULL;
|
heptagon *alt = NULL;
|
||||||
|
|
||||||
/*
|
|
||||||
if(hyperbolic) {
|
if(hyperbolic) {
|
||||||
dynamicval<eGeometry> g(geometry, gNormal);
|
dynamicval<eGeometry> g(geometry, gNormal);
|
||||||
alt = tailored_alloc<heptagon> (S7);
|
alt = tailored_alloc<heptagon> (S7);
|
||||||
@ -162,7 +172,6 @@ struct hrmap_arbi : hrmap {
|
|||||||
alt->cdata = NULL;
|
alt->cdata = NULL;
|
||||||
current_altmap = newAltMap(alt);
|
current_altmap = newAltMap(alt);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
transmatrix T = xpush(.01241) * spin(1.4117) * xpush(0.1241) * Id;
|
transmatrix T = xpush(.01241) * spin(1.4117) * xpush(0.1241) * Id;
|
||||||
arbi_matrix[origin] = make_pair(alt, T);
|
arbi_matrix[origin] = make_pair(alt, T);
|
||||||
@ -272,6 +281,7 @@ struct hrmap_arbi : hrmap {
|
|||||||
h1->zebraval = xt;
|
h1->zebraval = xt;
|
||||||
h1->c7 = newCell(h1->type, h1);
|
h1->c7 = newCell(h1->type, h1);
|
||||||
h1->alt = nullptr;
|
h1->alt = nullptr;
|
||||||
|
h1->cdata = nullptr;
|
||||||
h->c.connect(d, h1, e, m);
|
h->c.connect(d, h1, e, m);
|
||||||
|
|
||||||
arbi_matrix[h1] = make_pair(alt, T);
|
arbi_matrix[h1] = make_pair(alt, T);
|
||||||
|
Loading…
Reference in New Issue
Block a user