1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-11-19 23:25:13 +00:00

hemisphere model

This commit is contained in:
Zeno Rogue
2018-03-24 13:26:16 +01:00
parent 83b9e161ec
commit 74cc23f1c2
5 changed files with 48 additions and 7 deletions

View File

@@ -123,6 +123,42 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
return;
}
if(pmodel == mdHemisphere) {
ld ball = vid.ballangle * M_PI / 180;
using namespace hyperpoint_vec;
switch(cgclass) {
case gcHyperbolic: {
ret = H / H[2];
ret[2] = sqrt(1 - sqhypot2(ret));
break;
}
case gcEuclid: {
// stereographic projection to a sphere
auto hd = hdist0(H) / H[2];
if(hd == 0) H[2] = -1;
else {
ld x = 2 * hd / (1 + hd * hd);
ld y = x / hd;
H = H * x / (hd * H[2]);
H[2] = 1 - y;
}
break;
}
case gcSphere: {
ret = H;
break;
}
}
ret = rotmatrix(0, 2, ball) * ret;
ghcheck(ret, H);
return;
}
if(pmodel == mdHyperboloid) {
ld ball = vid.ballangle * M_PI / 180;