mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-07-01 17:32:51 +00:00
functions 'material' and 'ultra_normalize'
This commit is contained in:
parent
b2d0980091
commit
a5a49ce5c9
@ -381,7 +381,14 @@ EX ld sqhypot_d(int d, const hyperpoint& h) {
|
|||||||
EX ld hypot_d(int d, const hyperpoint& h) {
|
EX ld hypot_d(int d, const hyperpoint& h) {
|
||||||
return sqrt(sqhypot_d(d, h));
|
return sqrt(sqhypot_d(d, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief positive for a material vertex, 0 for ideal vertex, negative for ultra-ideal vertex */
|
||||||
|
EX ld material(const hyperpoint& h) {
|
||||||
|
if(sphere) return intval(h, Hypc);
|
||||||
|
else if(hyperbolic) return -intval(h, Hypc);
|
||||||
|
else return h[LDIM] - 1;
|
||||||
|
}
|
||||||
|
|
||||||
EX ld zlevel(const hyperpoint &h) {
|
EX ld zlevel(const hyperpoint &h) {
|
||||||
if(sl2) return sqrt(-intval(h, Hypc));
|
if(sl2) return sqrt(-intval(h, Hypc));
|
||||||
else if(translatable) return h[LDIM];
|
else if(translatable) return h[LDIM];
|
||||||
@ -412,6 +419,14 @@ EX hyperpoint normalize(hyperpoint H) {
|
|||||||
return H;
|
return H;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** like normalize but makes (ultra)ideal points material */
|
||||||
|
EX hyperpoint ultra_normalize(hyperpoint H) {
|
||||||
|
if(material(H) <= 0) {
|
||||||
|
H[MDIM-1] = hypot_d(MDIM-1, H) + 1e-6;
|
||||||
|
}
|
||||||
|
return normalize(H);
|
||||||
|
}
|
||||||
|
|
||||||
/** normalize, and in product geometry, also flatten */
|
/** normalize, and in product geometry, also flatten */
|
||||||
EX hyperpoint normalize_flat(hyperpoint h) {
|
EX hyperpoint normalize_flat(hyperpoint h) {
|
||||||
if(prod) return product_decompose(h).second;
|
if(prod) return product_decompose(h).second;
|
||||||
|
@ -811,7 +811,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);
|
h = zshift(normalize_flat(h), center_altitude * (1-x-y) + altitudes[a] * x + altitudes[b] * y);
|
||||||
hpcpush(h); return;
|
hpcpush(h); return;
|
||||||
}
|
}
|
||||||
if(sn::in() || !bt::in()) { hpcpush(normalize(h)); return; }
|
if(sn::in() || !bt::in()) { hpcpush(ultra_normalize(h)); return; }
|
||||||
hyperpoint res = bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]);
|
hyperpoint res = bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]);
|
||||||
hpcpush(res);
|
hpcpush(res);
|
||||||
});
|
});
|
||||||
@ -829,7 +829,7 @@ void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector
|
|||||||
}
|
}
|
||||||
if(nil)
|
if(nil)
|
||||||
h = nilv::on_geodesic(vertices[a], vertices[(a+1)%n], y * 1. / STEP);
|
h = nilv::on_geodesic(vertices[a], vertices[(a+1)%n], y * 1. / STEP);
|
||||||
if(sn::in() || !bt::in()) { hpcpush(normalize(h)); continue; }
|
if(sn::in() || !bt::in()) { hpcpush(ultra_normalize(h)); continue; }
|
||||||
hyperpoint res = bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]);
|
hyperpoint res = bt::parabolic3(h[0], h[1]) * xpush0(yy*h[2]);
|
||||||
hpcpush(res);
|
hpcpush(res);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user