mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 18:00:34 +00:00
created cellshapes for other 3D geometries
This commit is contained in:
parent
8215ac74ee
commit
2215e07fca
@ -110,9 +110,8 @@ EX void prepare() {
|
||||
|
||||
EX void prepare_walls() {
|
||||
|
||||
auto& hsh = cgi.heptshape;
|
||||
hsh = unique_ptr<subcellshape>(new subcellshape);
|
||||
auto& cs = hsh->faces;
|
||||
auto& hsh = get_hsh();
|
||||
auto& cs = hsh.faces;
|
||||
cs.clear();
|
||||
|
||||
auto pt = [&] (int x, int y, int z) { return asonov::tx*x/2 + asonov::ty*y/2 + asonov::tz*z/2 + C0; };
|
||||
@ -130,7 +129,7 @@ EX void prepare_walls() {
|
||||
cs.push_back({pt(-1,+1,-1), pt(-1,00,-1), pt(-1,-1,-1), pt(-1,-1,+1), pt(-1,+1,+1)});
|
||||
cs.push_back({pt(+1,-1,-1), pt(+1,-1,+1), pt(00,-1,+1), pt(-1,-1,+1), pt(-1,-1,-1)});
|
||||
|
||||
hsh->compute_hept();
|
||||
hsh.compute_hept();
|
||||
}
|
||||
|
||||
transmatrix coord_to_matrix(coord c, coord zero) {
|
||||
|
@ -472,54 +472,6 @@ EX namespace bt {
|
||||
return gm * where;
|
||||
}
|
||||
|
||||
subcellshape& get_cellshape(cell *c) override {
|
||||
if(cgi.heptshape)
|
||||
return *cgi.heptshape;
|
||||
|
||||
cgi.heptshape = (std::unique_ptr<subcellshape>) (new subcellshape);
|
||||
vector<hyperpoint>& res = cgi.heptshape->vertices_only;
|
||||
ld yy = log(2) / 2;
|
||||
auto add = [&] (hyperpoint h) {
|
||||
res.push_back(bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]));
|
||||
};
|
||||
switch(geometry) {
|
||||
case gBinary3:
|
||||
for(int x=-1; x<2; x++) for(int y=-1; y<2; y++) for(int z=-1; z<=1; z+=2)
|
||||
if(z == -1 || x != 0 || y != 0)
|
||||
add(point3(x,y,z));
|
||||
break;
|
||||
case gHoroTris: {
|
||||
ld r = sqrt(3)/6;
|
||||
ld r2 = r * 2;
|
||||
|
||||
hyperpoint shift3 = point3(0,0,-3);
|
||||
hyperpoint shift1 = point3(0,0,-1);
|
||||
|
||||
for(int i=0; i<3; i++) {
|
||||
hyperpoint t0 = spin(120 * degree * i) * point3(0,-r2,-1);
|
||||
add(t0);
|
||||
add(-2 * t0 + shift3);
|
||||
add(-2 * t0 + shift1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case gHoroRec: {
|
||||
ld r2 = sqrt(2);
|
||||
for(int y=-1; y<=1; y++) for(int x=-1; x<=1; x+=2) for(int z=-1; z<=1; z++)
|
||||
if(z == -1 || y != 0)
|
||||
add(point3(-r2*x*hororec_scale, -2*y*hororec_scale, z*.5));
|
||||
break;
|
||||
}
|
||||
case gHoroHex: {
|
||||
// complicated and unused for now -- todo
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
}
|
||||
cgi.heptshape->vertices_only_local = res;
|
||||
return *cgi.heptshape;
|
||||
}
|
||||
|
||||
ld spin_angle(cell *c, int d) override {
|
||||
if(WDIM == 3 || geometry == gBinary4 || geometry == gTernary) {
|
||||
return hrmap::spin_angle(c, d);
|
||||
@ -1116,6 +1068,126 @@ EX hyperpoint get_corner_horo_coordinates(cell *c, int i) {
|
||||
return point2(0, 0);
|
||||
}
|
||||
|
||||
vector<hyperpoint> make4(hyperpoint a, hyperpoint b, hyperpoint c) {
|
||||
return {a, b, b+c-a, c};
|
||||
}
|
||||
|
||||
vector<hyperpoint> make5(hyperpoint a, hyperpoint b, hyperpoint c) {
|
||||
return {a, (a+b)/2, b, b+c-a, c};
|
||||
}
|
||||
|
||||
EX void create_faces() {
|
||||
|
||||
if(geometry == gBinary3) {
|
||||
hyperpoint h00 = point3(-1,-1,-1);
|
||||
hyperpoint h01 = point3(-1,0,-1);
|
||||
hyperpoint h02 = point3(-1,+1,-1);
|
||||
hyperpoint h10 = point3(0,-1,-1);
|
||||
hyperpoint h11 = point3(0,0,-1);
|
||||
hyperpoint h12 = point3(0,+1,-1);
|
||||
hyperpoint h20 = point3(+1,-1,-1);
|
||||
hyperpoint h21 = point3(+1,0,-1);
|
||||
hyperpoint h22 = point3(+1,+1,-1);
|
||||
hyperpoint down = point3(0,0,2);
|
||||
|
||||
add_wall(0, make4(h11, h01, h10));
|
||||
add_wall(1, make4(h11, h21, h10));
|
||||
add_wall(2, make4(h11, h01, h12));
|
||||
add_wall(3, make4(h11, h21, h12));
|
||||
add_wall(4, make5(h00, h02, h00+down));
|
||||
add_wall(5, make5(h20, h22, h20+down));
|
||||
add_wall(6, make5(h00, h20, h00+down));
|
||||
add_wall(7, make5(h02, h22, h02+down));
|
||||
add_wall(8, make4(h22+down, h02+down, h20+down));
|
||||
}
|
||||
|
||||
if(GDIM == 3 && bt::in() && geometry == gHoroTris) {
|
||||
ld r = sqrt(3)/6;
|
||||
ld r1 = r;
|
||||
ld r2 = r * 2;
|
||||
|
||||
hyperpoint t0 = point3(0,-r2,-1);
|
||||
hyperpoint t1 = point3(+.5,r1,-1);
|
||||
hyperpoint t2 = point3(-.5,r1,-1);
|
||||
hyperpoint shift = point3(0,0,-3);
|
||||
hyperpoint down = point3(0,0,2);
|
||||
hyperpoint d0 = -2 * t0 + shift;
|
||||
hyperpoint d1 = -2 * t1 + shift;
|
||||
hyperpoint d2 = -2 * t2 + shift;
|
||||
|
||||
add_wall(0, {t0, t1, t2});
|
||||
add_wall(1, {d0, t1, t2});
|
||||
add_wall(2, {t0, d1, t2});
|
||||
add_wall(3, {t0, t1, d2});
|
||||
add_wall(4, make5(d2, d1, d2 + down));
|
||||
add_wall(5, make5(d0, d2, d0 + down));
|
||||
add_wall(6, make5(d1, d0, d1 + down));
|
||||
add_wall(7, {d0+down, d1+down, d2+down});
|
||||
}
|
||||
|
||||
if(geometry == gHoroRec) {
|
||||
ld r2 = sqrt(2);
|
||||
ld z = bt::hororec_scale;
|
||||
|
||||
hyperpoint a00 = point3(-r2*z,-2*z,-.5);
|
||||
hyperpoint a01 = point3(+r2*z,-2*z,-.5);
|
||||
hyperpoint a10 = point3(-r2*z, 0*z,-.5);
|
||||
hyperpoint a11 = point3(+r2*z, 0*z,-.5);
|
||||
hyperpoint a20 = point3(-r2*z,+2*z,-.5);
|
||||
hyperpoint a21 = point3(+r2*z,+2*z,-.5);
|
||||
|
||||
hyperpoint down = point3(0,0,1);
|
||||
|
||||
add_wall(0, make4(a00, a01, a10));
|
||||
add_wall(1, make4(a10, a11, a20));
|
||||
add_wall(2, make5(a01, a21, a01+down));
|
||||
add_wall(3, make4(a21, a20, a21+down));
|
||||
add_wall(4, make5(a20, a00, a20+down));
|
||||
add_wall(5, make4(a00, a01, a00+down));
|
||||
add_wall(6, make4(a00+down, a01+down, a20+down));
|
||||
}
|
||||
|
||||
if(geometry == gHoroHex) {
|
||||
ld z = log(3) / log(2) / 2;
|
||||
ld r3 = sqrt(3) / 2 * bt::horohex_scale;
|
||||
ld h = bt::horohex_scale / 2;
|
||||
hyperpoint down = point3(0,0,2*z);
|
||||
|
||||
for(int j=0; j<4; j++) for(int i=0; i<3; i++) {
|
||||
transmatrix T = cspin(0, 1, 2*M_PI*i/3);
|
||||
|
||||
hyperpoint hcenter = point3(0,0,-z);
|
||||
hyperpoint hu0 = T*point3(+h, +r3,-z);
|
||||
hyperpoint hu1 = T*point3(+h*3,+r3,-z);
|
||||
hyperpoint hd0 = T*point3(+h, -r3,-z);
|
||||
hyperpoint hd1 = T*point3(+h*3,-r3,-z);
|
||||
hyperpoint hcn = T*point3(-h*2,0, -z);
|
||||
hyperpoint hun = T*point3(-h*3,+r3,-z);
|
||||
hyperpoint hdn = T*point3(-h*3,-r3,-z);
|
||||
if(j == 0) add_wall(i, {hcenter, hu0, hu1, hd1, hd0});
|
||||
if(j == 1) add_wall(i+3, {hcn, hun, hdn});
|
||||
if(j == 2) add_wall(i+6, make4(hd1, hu1, hd1+down));
|
||||
if(j == 3) add_wall(i+9, make4(hun, hdn, hun+down));
|
||||
}
|
||||
|
||||
add_wall(12, {point3(3*h,r3,z), point3(0,2*r3,z), point3(-3*h,r3,z)});
|
||||
add_wall(13, {point3(3*h,r3,z), point3(3*h,-r3,z), point3(0,-2*r3,z), point3(-3*h,-r3,z), point3(-3*h,r3,z)});
|
||||
}
|
||||
|
||||
if(kite::in()) {
|
||||
auto kv = kite::make_walls();
|
||||
for(auto& v: kv.first) for(auto& h: v) {
|
||||
h = bt::deparabolic3(h);
|
||||
h = point3(h[1], h[2], h[0] / (log(2)/2));
|
||||
}
|
||||
for(int i=0; i<isize(kv.first); i++) {
|
||||
add_wall(i, kv.first[i]);
|
||||
}
|
||||
get_hsh().weights = kv.second;
|
||||
}
|
||||
|
||||
get_hsh().compute_hept();
|
||||
}
|
||||
|
||||
auto hooksw = addHook(hooks_swapdim, 100, [] {
|
||||
if(bt::in()) build_tmatrix();
|
||||
|
5
cell.cpp
5
cell.cpp
@ -75,7 +75,10 @@ struct hrmap {
|
||||
return currentmap->iadj(c, i);
|
||||
}
|
||||
|
||||
virtual subcellshape& get_cellshape(cell *c) { throw hr_exception("get_cellshape called unexpectedly"); }
|
||||
virtual subcellshape& get_cellshape(cell *c) {
|
||||
if(cgi.heptshape) return *cgi.heptshape;
|
||||
throw hr_exception("get_cellshape called unexpectedly");
|
||||
}
|
||||
|
||||
/** \brief in 3D honeycombs, returns a cellwalker res at cw->move(j) such that the face pointed at by cw and res share an edge */
|
||||
virtual cellwalker strafe(cellwalker cw, int j) { throw hr_exception("strafe called unexpectedly"); }
|
||||
|
@ -1280,10 +1280,9 @@ EX void generate() {
|
||||
|
||||
auto v = euc::get_shifttable();
|
||||
|
||||
auto& hsh = cgi.heptshape;
|
||||
hsh = unique_ptr<subcellshape>(new subcellshape);
|
||||
auto& hsh = get_hsh();
|
||||
|
||||
auto& cs = hsh->faces;
|
||||
auto& cs = hsh.faces;
|
||||
|
||||
cgi.loop = 4;
|
||||
cgi.schmid = 3;
|
||||
@ -1348,7 +1347,7 @@ EX void generate() {
|
||||
}
|
||||
}
|
||||
|
||||
hsh->compute_hept();
|
||||
hsh.compute_hept();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
6
fake.cpp
6
fake.cpp
@ -394,15 +394,15 @@ EX void generate() {
|
||||
cgi.face = ucgi.face;
|
||||
cgi.schmid = ucgi.schmid;
|
||||
|
||||
auto& hsh = cgi.heptshape;
|
||||
hsh = unique_ptr<subcellshape>(new subcellshape);
|
||||
auto& hsh = get_hsh();
|
||||
|
||||
*hsh = *ucgi.heptshape;
|
||||
hsh = *ucgi.heptshape;
|
||||
|
||||
for(int b=0; b<12; b++)
|
||||
cgi.spins[b] = ucgi.spins[b];
|
||||
|
||||
compute_around(true);
|
||||
hsh.compute_hept();
|
||||
reg3::compute_ultra();
|
||||
#endif
|
||||
}
|
||||
|
29
geometry.cpp
29
geometry.cpp
@ -100,10 +100,17 @@ struct gi_extension {
|
||||
|
||||
/** both for 'heptagon' 3D cells and subdivided 3D cells */
|
||||
struct subcellshape {
|
||||
/** \brief raw coordinates of vertices of all faces */
|
||||
vector<vector<hyperpoint>> faces;
|
||||
vector<vector<hyperpoint>> faces_local;
|
||||
/** \brief raw coordinates of all vertices in one vector */
|
||||
vector<hyperpoint> vertices_only;
|
||||
/** \brief cooked coordinates of vertices of all faces, computed from faces as: from_cellcenter * final_coords(v) */
|
||||
vector<vector<hyperpoint>> faces_local;
|
||||
/** \brief cooked coordinates of all vertices in one vector */
|
||||
vector<hyperpoint> vertices_only_local;
|
||||
/** \brief weights -- used to generate wall shapes in some geometries, empty otherwise */
|
||||
vector<vector<double>> weights;
|
||||
/** the center of every raw face */
|
||||
vector<hyperpoint> face_centers;
|
||||
vector<vector<char>> dirdist;
|
||||
hyperpoint cellcenter;
|
||||
@ -498,6 +505,17 @@ hpcshape
|
||||
};
|
||||
#endif
|
||||
|
||||
EX subcellshape& get_hsh() {
|
||||
if(!cgi.heptshape) cgi.heptshape = (unique_ptr<subcellshape>) (new subcellshape);
|
||||
return *cgi.heptshape;
|
||||
}
|
||||
|
||||
EX void add_wall(int i, const vector<hyperpoint>& h) {
|
||||
auto& f = get_hsh().faces;
|
||||
if(isize(f) <= i) f.resize(i+1);
|
||||
f[i] = h;
|
||||
}
|
||||
|
||||
/** values of hcrossf and hexf for the standard geometry. Since polygons are
|
||||
* usually drawn in this geometry, the scale in other geometries is usually
|
||||
* based on comparing these values to the values in the other geometry.
|
||||
@ -529,6 +547,8 @@ void geometry_information::prepare_basics() {
|
||||
|
||||
ld s3, beta;
|
||||
|
||||
heptshape = nullptr;
|
||||
|
||||
if(arcm::in() && !prod)
|
||||
ginf[gArchimedean].cclass = gcHyperbolic;
|
||||
|
||||
@ -661,6 +681,13 @@ void geometry_information::prepare_basics() {
|
||||
#if MAXMDIM >= 4
|
||||
if(reg3::in()) reg3::generate();
|
||||
if(euc::in(3)) euc::generate();
|
||||
#if CAP_SOLV
|
||||
else if(sn::in()) sn::create_faces();
|
||||
#endif
|
||||
#if CAP_BT
|
||||
else if(bt::in()) bt::create_faces();
|
||||
#endif
|
||||
else if(nil) nilv::create_faces();
|
||||
#endif
|
||||
|
||||
hybrid_finish:
|
||||
|
@ -688,6 +688,57 @@ EX namespace sn {
|
||||
int d2 = bt::celldistance3_approx(m->coords[h1].second, m->coords[h2].second);
|
||||
return d1 + d2 - abs(h1->distance - h2->distance);
|
||||
}
|
||||
|
||||
EX void create_faces() {
|
||||
if(geometry == gSol) {
|
||||
ld zstep = -log(2) / 2;
|
||||
ld bwh = vid.binary_width * zstep;
|
||||
auto pt = [&] (int x, int y, int z) { return xpush(bwh*x) * ypush(bwh*y) * zpush(zstep*z) * C0; };
|
||||
add_wall(0, {pt(-1,-1,-1), pt(-1,-1,+1), pt(-1,00,+1), pt(-1,+1,+1), pt(-1,+1,-1)});
|
||||
add_wall(1, {pt(-1,-1,-1), pt(00,-1,-1), pt(+1,-1,-1), pt(+1,-1,+1), pt(-1,-1,+1)});
|
||||
add_wall(2, {pt(+1,+1,-1), pt(+1,-1,-1), pt(00,-1,-1), pt(00,+1,-1)});
|
||||
add_wall(3, {pt(00,+1,-1), pt(00,-1,-1), pt(-1,-1,-1), pt(-1,+1,-1)});
|
||||
add_wall(4, {pt(+1,-1,-1), pt(+1,-1,+1), pt(+1,00,+1), pt(+1,+1,+1), pt(+1,+1,-1)});
|
||||
add_wall(5, {pt(-1,+1,-1), pt(00,+1,-1), pt(+1,+1,-1), pt(+1,+1,+1), pt(-1,+1,+1)});
|
||||
add_wall(6, {pt(-1,+1,+1), pt(+1,+1,+1), pt(+1,00,+1), pt(-1,00,+1)});
|
||||
add_wall(7, {pt(-1,00,+1), pt(+1,00,+1), pt(+1,-1,+1), pt(-1,-1,+1)});
|
||||
}
|
||||
|
||||
if(geometry == gNIH) {
|
||||
ld zstep = .5;
|
||||
ld bwh = vid.binary_width / 6;
|
||||
auto pt = [&] (int x, int y, int z) { return xpush(bwh*x) * ypush(bwh*y) * zpush(zstep*z) * C0; };
|
||||
add_wall(0, {pt(+3,-3,-1), pt(+3,-3,+1), pt(+3,+3,+1), pt(+3,+3,-1), pt(+3,+1,-1), pt(+3,-1,-1) });
|
||||
add_wall(1, {pt(-3,+3,-1), pt(-3,+3,+1), pt(+3,+3,+1), pt(+3,+3,-1), pt(+0,+3,-1) });
|
||||
add_wall(2, {pt(-3,-3,-1), pt(-3,-3,+1), pt(-3,+3,+1), pt(-3,+3,-1), pt(-3,+1,-1), pt(-3,-1,-1) });
|
||||
add_wall(3, {pt(-3,-3,-1), pt(-3,-3,+1), pt(+3,-3,+1), pt(+3,-3,-1), pt(+0,-3,-1)});
|
||||
|
||||
add_wall(4, {pt(-3,-3,+1), pt(-3,+3,+1), pt(+3,+3,+1), pt(+3,-3,+1)});
|
||||
|
||||
for(int i=0; i<6; i++) {
|
||||
int x = -3 + (i%2) * 3;
|
||||
int y = -3 + (i/2) * 2;
|
||||
add_wall(5+i, {pt(x,y,-1), pt(x+3,y,-1), pt(x+3,y+2,-1), pt(x,y+2,-1)});
|
||||
}
|
||||
}
|
||||
|
||||
if(geometry == gSolN) {
|
||||
ld zstep = -.5;
|
||||
ld bwh = vid.binary_width / 6;
|
||||
auto pt = [&] (int x, int y, int z) { return xpush(bwh*x) * ypush(bwh*y) * zpush(zstep*z) * C0; };
|
||||
add_wall(0, {pt(+3,-3,-1), pt(+3,-3,+1), pt(+3,-1,+1), pt(+3,+1,+1), pt(+3,+3,+1), pt(+3,+3,-1)});
|
||||
add_wall(1, {pt(-3,+3,-1), pt(00,+3,-1), pt(+3,+3,-1), pt(+3,+3,+1), pt(-3,+3,+1)});
|
||||
add_wall(2, {pt(-3,-3,-1), pt(-3,-3,+1), pt(-3,-1,+1), pt(-3,+1,+1), pt(-3,+3,+1), pt(-3,+3,-1)});
|
||||
add_wall(3, {pt(-3,-3,-1), pt(00,-3,-1), pt(+3,-3,-1), pt(+3,-3,+1), pt(-3,-3,+1)});
|
||||
add_wall(4, {pt(-3,+3,-1), pt(-3,-3,-1), pt(00,-3,-1), pt(00,+3,-1)});
|
||||
add_wall(5, {pt(00,+3,-1), pt(00,-3,-1), pt(+3,-3,-1), pt(+3,+3,-1)});
|
||||
add_wall(6, {pt(-3,-3,+1), pt(+3,-3,+1), pt(+3,-1,+1), pt(-3,-1,+1)});
|
||||
add_wall(7, {pt(-3,-1,+1), pt(+3,-1,+1), pt(+3,+1,+1), pt(-3,+1,+1)});
|
||||
add_wall(8, {pt(-3,+1,+1), pt(+3,+1,+1), pt(+3,+3,+1), pt(-3,+3,+1)});
|
||||
}
|
||||
|
||||
get_hsh().compute_hept();
|
||||
}
|
||||
EX }
|
||||
#endif
|
||||
|
||||
@ -983,6 +1034,15 @@ EX void show_niltorus3() {
|
||||
dialog::display();
|
||||
}
|
||||
|
||||
EX void create_faces() {
|
||||
for(int i=0; i<S7; i++) {
|
||||
vector<hyperpoint> fvs = nilv::current_ns().facevertices[i];
|
||||
using nilv::nilwidth;
|
||||
for(auto& h: fvs) h[0] *= nilwidth, h[1] *= nilwidth, h[2] *= nilwidth * nilwidth;
|
||||
add_wall(i, fvs);
|
||||
}
|
||||
}
|
||||
|
||||
EX }
|
||||
|
||||
EX bool in_s2xe() { return prod && hybrid::under_class() == gcSphere; }
|
||||
|
219
polygons.cpp
219
polygons.cpp
@ -795,10 +795,6 @@ void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector
|
||||
reverse(vertices.begin(), vertices.end()),
|
||||
reverse(weights.begin(), weights.end());
|
||||
|
||||
#if CAP_BT
|
||||
ld yy = log(2) / 2;
|
||||
#endif
|
||||
|
||||
bshape(shWall3D[id], PPR::WALL);
|
||||
last->flags |= POLY_TRIANGLES | POLY_PRINTABLE;
|
||||
|
||||
@ -855,15 +851,7 @@ void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector
|
||||
h = zshift(normalize_flat(h), center_altitude * (1-x-y) + altitudes[a] * x + altitudes[b] * y);
|
||||
hpcpush(h); return;
|
||||
}
|
||||
if(sn::in() || !bt::in()) { hpcpush(ultra_normalize(h)); return; }
|
||||
#if CAP_BT
|
||||
if(bt::in()) {
|
||||
hyperpoint res = bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]);
|
||||
hpcpush(res);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
hpcpush(h);
|
||||
hpcpush(final_coords(h));
|
||||
});
|
||||
}
|
||||
|
||||
@ -875,19 +863,12 @@ void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector
|
||||
hyperpoint h = (vertices[a] * (STEP-y) + vertices[(a+1)%n] * y)/STEP;
|
||||
if(prod) {
|
||||
h = zshift(normalize_flat(h), (altitudes[a] * (STEP-y) + altitudes[(a+1)%n] * y) / STEP);
|
||||
hpcpush(h); continue;
|
||||
hpcpush(h);
|
||||
}
|
||||
if(nil)
|
||||
h = nilv::on_geodesic(vertices[a], vertices[(a+1)%n], y * 1. / STEP);
|
||||
if(sn::in() || !bt::in()) { hpcpush(ultra_normalize(h)); continue; }
|
||||
#if CAP_BT
|
||||
if(bt::in()) {
|
||||
hyperpoint res = bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]);
|
||||
hpcpush(res);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
hpcpush(h);
|
||||
else if(nil)
|
||||
hpcpush(nilv::on_geodesic(vertices[a], vertices[(a+1)%n], y * 1. / STEP));
|
||||
else
|
||||
hpcpush(final_coords(h));
|
||||
}
|
||||
hpcpush(hpc[last->s]);
|
||||
}
|
||||
@ -909,14 +890,6 @@ void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector
|
||||
shPlainWall3D[id] = shWall3D[id]; // force_triangles ? shWall3D[id] : shWireframe3D[id];
|
||||
}
|
||||
|
||||
vector<hyperpoint> make4(hyperpoint a, hyperpoint b, hyperpoint c) {
|
||||
return {a, b, b+c-a, c};
|
||||
}
|
||||
|
||||
vector<hyperpoint> make5(hyperpoint a, hyperpoint b, hyperpoint c) {
|
||||
return {a, (a+b)/2, b, b+c-a, c};
|
||||
}
|
||||
|
||||
void geometry_information::reserve_wall3d(int i) {
|
||||
shWall3D.resize(i);
|
||||
shPlainWall3D.resize(i);
|
||||
@ -929,109 +902,11 @@ void geometry_information::create_wall3d() {
|
||||
if(WDIM == 2) return;
|
||||
reserve_wall3d(kite::in() ? 22 : hybri ? 0 : S7);
|
||||
|
||||
#if CAP_BT
|
||||
if(GDIM == 3 && bt::in() && geometry == gBinary3) {
|
||||
hyperpoint h00 = point3(-1,-1,-1);
|
||||
hyperpoint h01 = point3(-1,0,-1);
|
||||
hyperpoint h02 = point3(-1,+1,-1);
|
||||
hyperpoint h10 = point3(0,-1,-1);
|
||||
hyperpoint h11 = point3(0,0,-1);
|
||||
hyperpoint h12 = point3(0,+1,-1);
|
||||
hyperpoint h20 = point3(+1,-1,-1);
|
||||
hyperpoint h21 = point3(+1,0,-1);
|
||||
hyperpoint h22 = point3(+1,+1,-1);
|
||||
hyperpoint down = point3(0,0,2);
|
||||
|
||||
make_wall(0, make4(h11, h01, h10));
|
||||
make_wall(1, make4(h11, h21, h10));
|
||||
make_wall(2, make4(h11, h01, h12));
|
||||
make_wall(3, make4(h11, h21, h12));
|
||||
make_wall(4, make5(h00, h02, h00+down));
|
||||
make_wall(5, make5(h20, h22, h20+down));
|
||||
make_wall(6, make5(h00, h20, h00+down));
|
||||
make_wall(7, make5(h02, h22, h02+down));
|
||||
make_wall(8, make4(h22+down, h02+down, h20+down));
|
||||
}
|
||||
|
||||
if(GDIM == 3 && bt::in() && geometry == gHoroTris) {
|
||||
ld r = sqrt(3)/6;
|
||||
ld r1 = r;
|
||||
ld r2 = r * 2;
|
||||
|
||||
hyperpoint t0 = point3(0,-r2,-1);
|
||||
hyperpoint t1 = point3(+.5,r1,-1);
|
||||
hyperpoint t2 = point3(-.5,r1,-1);
|
||||
hyperpoint shift = point3(0,0,-3);
|
||||
hyperpoint down = point3(0,0,2);
|
||||
hyperpoint d0 = -2 * t0 + shift;
|
||||
hyperpoint d1 = -2 * t1 + shift;
|
||||
hyperpoint d2 = -2 * t2 + shift;
|
||||
|
||||
make_wall(0, {t0, t1, t2});
|
||||
make_wall(1, {d0, t1, t2});
|
||||
make_wall(2, {t0, d1, t2});
|
||||
make_wall(3, {t0, t1, d2});
|
||||
make_wall(4, make5(d2, d1, d2 + down));
|
||||
make_wall(5, make5(d0, d2, d0 + down));
|
||||
make_wall(6, make5(d1, d0, d1 + down));
|
||||
make_wall(7, {d0+down, d1+down, d2+down});
|
||||
}
|
||||
|
||||
if(geometry == gHoroRec) {
|
||||
ld r2 = sqrt(2);
|
||||
ld z = bt::hororec_scale;
|
||||
|
||||
hyperpoint a00 = point3(-r2*z,-2*z,-.5);
|
||||
hyperpoint a01 = point3(+r2*z,-2*z,-.5);
|
||||
hyperpoint a10 = point3(-r2*z, 0*z,-.5);
|
||||
hyperpoint a11 = point3(+r2*z, 0*z,-.5);
|
||||
hyperpoint a20 = point3(-r2*z,+2*z,-.5);
|
||||
hyperpoint a21 = point3(+r2*z,+2*z,-.5);
|
||||
|
||||
hyperpoint down = point3(0,0,1);
|
||||
|
||||
make_wall(0, make4(a00, a01, a10));
|
||||
make_wall(1, make4(a10, a11, a20));
|
||||
make_wall(2, make5(a01, a21, a01+down));
|
||||
make_wall(3, make4(a21, a20, a21+down));
|
||||
make_wall(4, make5(a20, a00, a20+down));
|
||||
make_wall(5, make4(a00, a01, a00+down));
|
||||
make_wall(6, make4(a00+down, a01+down, a20+down));
|
||||
}
|
||||
|
||||
if(geometry == gHoroHex) {
|
||||
ld z = log(3) / log(2) / 2;
|
||||
ld r3 = sqrt(3) / 2 * bt::horohex_scale;
|
||||
ld h = bt::horohex_scale / 2;
|
||||
hyperpoint down = point3(0,0,2*z);
|
||||
|
||||
for(int j=0; j<4; j++) for(int i=0; i<3; i++) {
|
||||
transmatrix T = cspin(0, 1, 2*M_PI*i/3);
|
||||
|
||||
hyperpoint hcenter = point3(0,0,-z);
|
||||
hyperpoint hu0 = T*point3(+h, +r3,-z);
|
||||
hyperpoint hu1 = T*point3(+h*3,+r3,-z);
|
||||
hyperpoint hd0 = T*point3(+h, -r3,-z);
|
||||
hyperpoint hd1 = T*point3(+h*3,-r3,-z);
|
||||
hyperpoint hcn = T*point3(-h*2,0, -z);
|
||||
hyperpoint hun = T*point3(-h*3,+r3,-z);
|
||||
hyperpoint hdn = T*point3(-h*3,-r3,-z);
|
||||
if(j == 0) make_wall(i, {hcenter, hu0, hu1, hd1, hd0});
|
||||
if(j == 1) make_wall(i+3, {hcn, hun, hdn});
|
||||
if(j == 2) make_wall(i+6, make4(hd1, hu1, hd1+down));
|
||||
if(j == 3) make_wall(i+9, make4(hun, hdn, hun+down));
|
||||
}
|
||||
|
||||
make_wall(12, {point3(3*h,r3,z), point3(0,2*r3,z), point3(-3*h,r3,z)});
|
||||
make_wall(13, {point3(3*h,r3,z), point3(3*h,-r3,z), point3(0,-2*r3,z), point3(-3*h,-r3,z), point3(-3*h,r3,z)});
|
||||
}
|
||||
#endif
|
||||
|
||||
if(prod) {
|
||||
if(hybri) {
|
||||
walloffsets.clear();
|
||||
}
|
||||
|
||||
if(reg3::in() && !PURE) {
|
||||
else if(reg3::in() && !PURE) {
|
||||
int tot = 0;
|
||||
for(auto& ss: cgi.subshapes) tot += isize(ss.faces);
|
||||
reserve_wall3d(tot);
|
||||
@ -1046,79 +921,19 @@ void geometry_information::create_wall3d() {
|
||||
return;
|
||||
}
|
||||
|
||||
if(euc::in() || reg3::in() || asonov::in()) {
|
||||
else {
|
||||
auto& faces = cgi.heptshape->faces;
|
||||
for(int w=0; w<isize(faces); w++)
|
||||
make_wall(w, faces[w]);
|
||||
}
|
||||
|
||||
if(geometry == gSol) {
|
||||
ld zstep = -log(2) / 2;
|
||||
ld bwh = vid.binary_width * zstep;
|
||||
auto pt = [&] (int x, int y, int z) { return xpush(bwh*x) * ypush(bwh*y) * zpush(zstep*z) * C0; };
|
||||
make_wall(0, {pt(-1,-1,-1), pt(-1,-1,+1), pt(-1,00,+1), pt(-1,+1,+1), pt(-1,+1,-1)});
|
||||
make_wall(1, {pt(-1,-1,-1), pt(00,-1,-1), pt(+1,-1,-1), pt(+1,-1,+1), pt(-1,-1,+1)});
|
||||
make_wall(2, {pt(+1,+1,-1), pt(+1,-1,-1), pt(00,-1,-1), pt(00,+1,-1)});
|
||||
make_wall(3, {pt(00,+1,-1), pt(00,-1,-1), pt(-1,-1,-1), pt(-1,+1,-1)});
|
||||
make_wall(4, {pt(+1,-1,-1), pt(+1,-1,+1), pt(+1,00,+1), pt(+1,+1,+1), pt(+1,+1,-1)});
|
||||
make_wall(5, {pt(-1,+1,-1), pt(00,+1,-1), pt(+1,+1,-1), pt(+1,+1,+1), pt(-1,+1,+1)});
|
||||
make_wall(6, {pt(-1,+1,+1), pt(+1,+1,+1), pt(+1,00,+1), pt(-1,00,+1)});
|
||||
make_wall(7, {pt(-1,00,+1), pt(+1,00,+1), pt(+1,-1,+1), pt(-1,-1,+1)});
|
||||
}
|
||||
|
||||
if(geometry == gNIH) {
|
||||
ld zstep = .5;
|
||||
ld bwh = vid.binary_width / 6;
|
||||
auto pt = [&] (int x, int y, int z) { return xpush(bwh*x) * ypush(bwh*y) * zpush(zstep*z) * C0; };
|
||||
make_wall(0, {pt(+3,-3,-1), pt(+3,-3,+1), pt(+3,+3,+1), pt(+3,+3,-1), pt(+3,+1,-1), pt(+3,-1,-1) });
|
||||
make_wall(1, {pt(-3,+3,-1), pt(-3,+3,+1), pt(+3,+3,+1), pt(+3,+3,-1), pt(+0,+3,-1) });
|
||||
make_wall(2, {pt(-3,-3,-1), pt(-3,-3,+1), pt(-3,+3,+1), pt(-3,+3,-1), pt(-3,+1,-1), pt(-3,-1,-1) });
|
||||
make_wall(3, {pt(-3,-3,-1), pt(-3,-3,+1), pt(+3,-3,+1), pt(+3,-3,-1), pt(+0,-3,-1)});
|
||||
|
||||
make_wall(4, {pt(-3,-3,+1), pt(-3,+3,+1), pt(+3,+3,+1), pt(+3,-3,+1)});
|
||||
|
||||
for(int i=0; i<6; i++) {
|
||||
int x = -3 + (i%2) * 3;
|
||||
int y = -3 + (i/2) * 2;
|
||||
make_wall(5+i, {pt(x,y,-1), pt(x+3,y,-1), pt(x+3,y+2,-1), pt(x,y+2,-1)});
|
||||
auto& we = cgi.heptshape->weights;
|
||||
if(we.empty()) {
|
||||
for(int w=0; w<isize(faces); w++)
|
||||
make_wall(w, faces[w]);
|
||||
}
|
||||
else {
|
||||
for(int w=0; w<isize(faces); w++)
|
||||
make_wall(w, faces[w], we[w]);
|
||||
}
|
||||
}
|
||||
|
||||
if(geometry == gSolN) {
|
||||
ld zstep = -.5;
|
||||
ld bwh = vid.binary_width / 6;
|
||||
auto pt = [&] (int x, int y, int z) { return xpush(bwh*x) * ypush(bwh*y) * zpush(zstep*z) * C0; };
|
||||
make_wall(0, {pt(+3,-3,-1), pt(+3,-3,+1), pt(+3,-1,+1), pt(+3,+1,+1), pt(+3,+3,+1), pt(+3,+3,-1)});
|
||||
make_wall(1, {pt(-3,+3,-1), pt(00,+3,-1), pt(+3,+3,-1), pt(+3,+3,+1), pt(-3,+3,+1)});
|
||||
make_wall(2, {pt(-3,-3,-1), pt(-3,-3,+1), pt(-3,-1,+1), pt(-3,+1,+1), pt(-3,+3,+1), pt(-3,+3,-1)});
|
||||
make_wall(3, {pt(-3,-3,-1), pt(00,-3,-1), pt(+3,-3,-1), pt(+3,-3,+1), pt(-3,-3,+1)});
|
||||
make_wall(4, {pt(-3,+3,-1), pt(-3,-3,-1), pt(00,-3,-1), pt(00,+3,-1)});
|
||||
make_wall(5, {pt(00,+3,-1), pt(00,-3,-1), pt(+3,-3,-1), pt(+3,+3,-1)});
|
||||
make_wall(6, {pt(-3,-3,+1), pt(+3,-3,+1), pt(+3,-1,+1), pt(-3,-1,+1)});
|
||||
make_wall(7, {pt(-3,-1,+1), pt(+3,-1,+1), pt(+3,+1,+1), pt(-3,+1,+1)});
|
||||
make_wall(8, {pt(-3,+1,+1), pt(+3,+1,+1), pt(+3,+3,+1), pt(-3,+3,+1)});
|
||||
}
|
||||
|
||||
if(nil) {
|
||||
for(int i=0; i<S7; i++) {
|
||||
vector<hyperpoint> fvs = nilv::current_ns().facevertices[i];
|
||||
using nilv::nilwidth;
|
||||
for(auto& h: fvs) h[0] *= nilwidth, h[1] *= nilwidth, h[2] *= nilwidth * nilwidth;
|
||||
make_wall(i, fvs);
|
||||
}
|
||||
}
|
||||
|
||||
#if CAP_BT
|
||||
if(kite::in()) {
|
||||
auto kv = kite::make_walls();
|
||||
for(auto& v: kv.first) for(auto& h: v) {
|
||||
h = bt::deparabolic3(h);
|
||||
h = point3(h[1], h[2], h[0] / (log(2)/2));
|
||||
}
|
||||
for(int i=0; i<isize(kv.first); i++) make_wall(i, kv.first[i], kv.second[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
wallstart.push_back(isize(raywall));
|
||||
compute_cornerbonus();
|
||||
}
|
||||
|
29
reg3.cpp
29
reg3.cpp
@ -13,14 +13,26 @@
|
||||
namespace hr {
|
||||
#if MAXMDIM >= 4
|
||||
|
||||
EX hyperpoint final_coords(hyperpoint h) {
|
||||
if(sn::in() || !bt::in())
|
||||
return ultra_normalize(h);
|
||||
#if CAP_BT
|
||||
if(bt::in()) {
|
||||
ld yy = log(2) / 2;
|
||||
return bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]);
|
||||
}
|
||||
#endif
|
||||
return h;
|
||||
}
|
||||
|
||||
void subcellshape::compute_common() {
|
||||
reg3::make_vertices_only(vertices_only, faces);
|
||||
|
||||
faces_local = faces;
|
||||
for(auto& face: faces_local) for(auto& v: face) v = from_cellcenter * v;
|
||||
for(auto& face: faces_local) for(auto& v: face) v = from_cellcenter * final_coords(v);
|
||||
|
||||
vertices_only_local = vertices_only;
|
||||
for(auto& v: vertices_only_local) v = from_cellcenter * v;
|
||||
for(auto& v: vertices_only_local) v = from_cellcenter * final_coords(v);
|
||||
|
||||
int N = isize(faces);
|
||||
|
||||
@ -174,13 +186,12 @@ EX namespace reg3 {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& hsh = cgi.heptshape;
|
||||
hsh = unique_ptr<subcellshape>(new subcellshape);
|
||||
auto& hsh = get_hsh();
|
||||
|
||||
int& loop = cgi.loop;
|
||||
int& face = cgi.face;
|
||||
auto& spins = cgi.spins;
|
||||
auto& cellshape = hsh->faces;
|
||||
auto& cellshape = hsh.faces;
|
||||
auto& adjcheck = cgi.adjcheck;
|
||||
|
||||
int& mid = cgi.schmid;
|
||||
@ -324,7 +335,7 @@ EX namespace reg3 {
|
||||
for(auto& vv: cellshape) for(auto& v: vv) v = T * v;
|
||||
}
|
||||
|
||||
hsh->compute_hept();
|
||||
hsh.compute_hept();
|
||||
compute_ultra();
|
||||
|
||||
generate_subcells();
|
||||
@ -1130,12 +1141,12 @@ EX namespace reg3 {
|
||||
|
||||
void build_reps() {
|
||||
// start_game();
|
||||
auto& hsh = cgi.heptshape;
|
||||
auto& hsh = get_hsh();
|
||||
|
||||
set<coord> boundaries;
|
||||
|
||||
for(int a=0; a<12; a++)
|
||||
for(int b=0; b<12; b++) if(hsh->dirdist[a][b] == 1) {
|
||||
for(int b=0; b<12; b++) if(hsh.dirdist[a][b] == 1) {
|
||||
coord res = crystal::c0;
|
||||
int sa = a, sb = b;
|
||||
do {
|
||||
@ -1144,7 +1155,7 @@ EX namespace reg3 {
|
||||
sa = flip(sa);
|
||||
sb = flip(sb);
|
||||
swap(sa, sb);
|
||||
sb = hsh->next_dir[sa][sb];
|
||||
sb = hsh.next_dir[sa][sb];
|
||||
// sb = next_dirsa][sb];
|
||||
}
|
||||
while(a != sa || b != sb);
|
||||
|
Loading…
Reference in New Issue
Block a user