1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-01-26 00:47:00 +00:00

fisheye model

This commit is contained in:
Zeno Rogue 2018-04-18 20:52:17 +02:00
parent 14a4375cf0
commit f1bcd91de5
4 changed files with 22 additions and 4 deletions

View File

@ -534,7 +534,8 @@ namespace conformal {
"disk", "half-plane", "band", "polygonal", "polynomial", "disk", "half-plane", "band", "polygonal", "polynomial",
"azimuthal equidistant", "azimuthal equi-area", "azimuthal equidistant", "azimuthal equi-area",
"ball model", "Minkowski hyperboloid", "hemisphere", "ball model", "Minkowski hyperboloid", "hemisphere",
"band equidistant", "band equi-area", "sinusoidal", "two-point equidistant" "band equidistant", "band equi-area", "sinusoidal", "two-point equidistant",
"fisheye"
}; };
string get_model_name(eModel pm) { string get_model_name(eModel pm) {
@ -640,6 +641,8 @@ namespace conformal {
pmodel = eModel(12); pmodel = eModel(12);
else if(uni == '$') else if(uni == '$')
pmodel = eModel(13); pmodel = eModel(13);
else if(uni == '%')
pmodel = eModel(14);
else if(uni == '6') else if(uni == '6')
vid.alpha = 1, vid.scale = 1; vid.alpha = 1, vid.scale = 1;
else if(uni == 'z') else if(uni == 'z')

View File

@ -927,6 +927,7 @@ enum eModel {
mdDisk, mdHalfplane, mdBand, mdPolygonal, mdPolynomial, mdDisk, mdHalfplane, mdBand, mdPolygonal, mdPolynomial,
mdEquidistant, mdEquiarea, mdBall, mdHyperboloid, mdEquidistant, mdEquiarea, mdBall, mdHyperboloid,
mdHemisphere, mdBandEquidistant, mdBandEquiarea, mdSinusoidal, mdTwoPoint, mdHemisphere, mdBandEquidistant, mdBandEquiarea, mdSinusoidal, mdTwoPoint,
mdFisheye,
mdGUARD, mdUnchanged }; mdGUARD, mdUnchanged };
namespace conformal { namespace conformal {

View File

@ -222,6 +222,16 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
return; return;
} }
if(pmodel == mdFisheye) {
ret[0] = H[0] / tz;
ret[1] = H[1] / tz;
ld hypot = sqrt(1 + ret[0]*ret[0] + ret[1]*ret[1]);
ret[0] /= hypot;
ret[1] /= hypot;
ghcheck(ret, H);
return;
}
ld zlev = 1; ld zlev = 1;
bool zlev_used = false; bool zlev_used = false;

View File

@ -549,7 +549,9 @@ void drawpolyline(polytodraw& p) {
return; // too large! return; // too large!
} }
if((spherespecial > 0 || (sphere && mdAzimuthalEqui())) && !(poly_flags & POLY_ISSIDE)) { bool equi = mdAzimuthalEqui() || pmodel == mdFisheye;
if((spherespecial > 0 || (sphere && equi)) && !(poly_flags & POLY_ISSIDE)) {
double rarea = 0; double rarea = 0;
for(int i=0; i<size(glcoords)-1; i++) for(int i=0; i<size(glcoords)-1; i++)
rarea += glcoords[i][0] * glcoords[i+1][1] - glcoords[i][1] * glcoords[i+1][0]; rarea += glcoords[i][0] * glcoords[i+1][1] - glcoords[i][1] * glcoords[i+1][0];
@ -583,8 +585,10 @@ void drawpolyline(polytodraw& p) {
lastl = l; lastl = l;
} }
if(mdAzimuthalEqui() && (poly_flags & POLY_INVERSE)) { bool nofill = false;
if(abs(zlevel(pp.V * C0) - 1) < 1e-6) {
if(equi && (poly_flags & POLY_INVERSE)) {
if(abs(zlevel(pp.V * C0) - 1) < 1e-6 && !pp.tinf) {
// we should fill the other side // we should fill the other side
ld h = atan2(glcoords[0][0], glcoords[0][1]); ld h = atan2(glcoords[0][0], glcoords[0][1]);
for(int i=0; i<=360; i++) { for(int i=0; i<=360; i++) {