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",
"azimuthal equidistant", "azimuthal equi-area",
"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) {
@ -640,6 +641,8 @@ namespace conformal {
pmodel = eModel(12);
else if(uni == '$')
pmodel = eModel(13);
else if(uni == '%')
pmodel = eModel(14);
else if(uni == '6')
vid.alpha = 1, vid.scale = 1;
else if(uni == 'z')

View File

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

View File

@ -222,6 +222,16 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
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;
bool zlev_used = false;

View File

@ -548,8 +548,10 @@ void drawpolyline(polytodraw& p) {
if(abs(p[0]) > poly_limit || abs(p[1]) > poly_limit)
return; // too large!
}
bool equi = mdAzimuthalEqui() || pmodel == mdFisheye;
if((spherespecial > 0 || (sphere && mdAzimuthalEqui())) && !(poly_flags & POLY_ISSIDE)) {
if((spherespecial > 0 || (sphere && equi)) && !(poly_flags & POLY_ISSIDE)) {
double rarea = 0;
for(int i=0; i<size(glcoords)-1; i++)
rarea += glcoords[i][0] * glcoords[i+1][1] - glcoords[i][1] * glcoords[i+1][0];
@ -582,9 +584,11 @@ void drawpolyline(polytodraw& p) {
}
lastl = l;
}
bool nofill = false;
if(mdAzimuthalEqui() && (poly_flags & POLY_INVERSE)) {
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
ld h = atan2(glcoords[0][0], glcoords[0][1]);
for(int i=0; i<=360; i++) {