1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-22 09:27:40 +00:00

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;