functions 'material' and 'ultra_normalize'

This commit is contained in:
Zeno Rogue 2020-05-15 11:43:13 +02:00
parent b2d0980091
commit a5a49ce5c9
2 changed files with 18 additions and 3 deletions

View File

@ -381,7 +381,14 @@ EX ld sqhypot_d(int d, const hyperpoint& h) {
EX ld hypot_d(int d, const hyperpoint& 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) {
if(sl2) return sqrt(-intval(h, Hypc));
else if(translatable) return h[LDIM];
@ -412,6 +419,14 @@ EX hyperpoint normalize(hyperpoint 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 */
EX hyperpoint normalize_flat(hyperpoint h) {
if(prod) return product_decompose(h).second;

View File

@ -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);
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]);
hpcpush(res);
});
@ -829,7 +829,7 @@ void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector
}
if(nil)
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]);
hpcpush(res);
}