mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 15:40:26 +00:00
Joukowsky transform, and better inverted Poincare
This commit is contained in:
parent
b44063f500
commit
cbb53cfe68
@ -195,7 +195,7 @@ void eyewidth_translate(int ed) {
|
||||
void stereo::set_projection(int ed) {
|
||||
DEBB(DF_GRAPH, (debugfile,"stereo::set_projection\n"));
|
||||
|
||||
start_projection(ed, pmodel == mdDisk && !spherespecial);
|
||||
start_projection(ed, pmodel == mdDisk && !spherespecial && !(hyperbolic && vid.alpha <= -1));
|
||||
|
||||
if(!using_perspective) {
|
||||
glhr::projection_multiply(glhr::ortho(vid.xres/2, -vid.yres/2, abs(stereo::scrdist) + 30000));
|
||||
|
@ -578,7 +578,7 @@ namespace conformal {
|
||||
"azimuthal equidistant", "azimuthal equi-area",
|
||||
"ball model", "Minkowski hyperboloid", "hemisphere",
|
||||
"band equidistant", "band equi-area", "sinusoidal", "two-point equidistant",
|
||||
"fisheye"
|
||||
"fisheye", "Joukovsky", "Joukovsky/inversion"
|
||||
};
|
||||
|
||||
string get_model_name(eModel pm) {
|
||||
|
2
hyper.h
2
hyper.h
@ -1264,7 +1264,7 @@ enum eModel {
|
||||
mdDisk, mdHalfplane, mdBand, mdPolygonal, mdPolynomial,
|
||||
mdEquidistant, mdEquiarea, mdBall, mdHyperboloid,
|
||||
mdHemisphere, mdBandEquidistant, mdBandEquiarea, mdSinusoidal, mdTwoPoint,
|
||||
mdFisheye,
|
||||
mdFisheye, mdJoukowsky, mdJoukowskyInverted,
|
||||
mdGUARD, mdUnchanged, mdHyperboloidFlat };
|
||||
|
||||
namespace conformal {
|
||||
|
19
hypgraph.cpp
19
hypgraph.cpp
@ -406,6 +406,25 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(among(pmodel, mdJoukowsky, mdJoukowskyInverted)) {
|
||||
ld x0, y0;
|
||||
x0 = H[0] / tz;
|
||||
y0 = H[1] / tz;
|
||||
ld r = hypot(x0, y0);
|
||||
ld c = x0 / r;
|
||||
ld s = y0 / r;
|
||||
ret[0] = (r + 1/r) * c / 2;
|
||||
ret[1] = (r - 1/r) * s / 2;
|
||||
ret[2] = 0;
|
||||
if(pmodel == mdJoukowskyInverted) {
|
||||
ld r2 = sqhypot2(ret);
|
||||
ret[0] = ret[0] / r2;
|
||||
ret[1] = -ret[1] / r2;
|
||||
}
|
||||
ghcheck(ret,H);
|
||||
return;
|
||||
}
|
||||
|
||||
if(pmodel == mdHalfplane) {
|
||||
// Poincare to half-plane
|
||||
|
||||
|
116
polygons.cpp
116
polygons.cpp
@ -722,6 +722,60 @@ ld glhypot2(glvertex a, glvertex b) {
|
||||
return (a[0]-b[0]) * (a[0]-b[0]) + (a[1]-b[1]) * (a[1]-b[1]) + (a[2]-b[2]) * (a[2]-b[2]);
|
||||
}
|
||||
|
||||
void compute_side_by_centerin(dqi_poly *p, bool& nofill) {
|
||||
|
||||
hyperpoint hscr;
|
||||
hyperpoint h1 = p->V * p->intester;
|
||||
if(is_behind(h1)) {
|
||||
if(sphere) {
|
||||
for(int i=0; i<3; i++) h1[i] = -h1[i];
|
||||
poly_flags &= ~POLY_CENTERIN;
|
||||
}
|
||||
else
|
||||
nofill = true;
|
||||
}
|
||||
applymodel(h1, hscr); hscr[0] *= vid.radius; hscr[1] *= vid.radius * vid.stretch;
|
||||
for(int i=0; i<isize(glcoords)-1; i++) {
|
||||
double x1 = glcoords[i][0] - hscr[0];
|
||||
double y1 = glcoords[i][1] - hscr[1];
|
||||
double x2 = glcoords[i+1][0] - hscr[0];
|
||||
double y2 = glcoords[i+1][1] - hscr[1];
|
||||
if(asign(y1, y2)) {
|
||||
ld x = xcross(x1, y1, x2, y2);
|
||||
if(x < -1e-6) poly_flags ^= POLY_CENTERIN;
|
||||
else if (x < 1e-6) nofill = true;
|
||||
}
|
||||
}
|
||||
|
||||
poly_flags &= ~POLY_INVERSE;
|
||||
if(poly_flags & POLY_CENTERIN) {
|
||||
poly_flags |= POLY_INVERSE;
|
||||
/* nofill = true;
|
||||
outline = (flags & POLY_CENTERIN) ? 0x00FF00FF : 0xFF0000FF;
|
||||
addpoint(hscr); */
|
||||
}
|
||||
|
||||
/*
|
||||
if(poly_flags & POLY_BADCENTERIN) {
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0]+10, hscr[1]*vid.stretch, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0], hscr[1]*vid.stretch+10, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0]-10, hscr[1]*vid.stretch, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0], hscr[1]*vid.stretch-10, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0]+10, hscr[1]*vid.stretch, hscr[2]));
|
||||
} */
|
||||
}
|
||||
|
||||
void compute_side_by_area() {
|
||||
|
||||
double rarea = 0;
|
||||
for(int i=0; i<isize(glcoords)-1; i++)
|
||||
rarea += glcoords[i][0] * glcoords[i+1][1] - glcoords[i][1] * glcoords[i+1][0];
|
||||
rarea += glcoords.back()[0] * glcoords[0][1] - glcoords.back()[1] * glcoords[0][0];
|
||||
|
||||
if(rarea>0)
|
||||
poly_flags ^= POLY_INVERSE;
|
||||
}
|
||||
|
||||
void dqi_poly::draw() {
|
||||
|
||||
if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) {
|
||||
@ -899,67 +953,21 @@ void dqi_poly::draw() {
|
||||
if(around_center) return;
|
||||
}
|
||||
|
||||
if(sphere && (spherespecial > 0 || equi) && !(poly_flags & POLY_ISSIDE)) {
|
||||
if(((sphere && (spherespecial > 0 || equi)) || (pmodel == mdJoukowsky && hyperbolic) || (pmodel == mdDisk && hyperbolic && vid.alpha <= -1)) && !(poly_flags & POLY_ISSIDE)) {
|
||||
|
||||
if(!tinf) {
|
||||
|
||||
hyperpoint hscr;
|
||||
hyperpoint h1 = V * intester;
|
||||
if(is_behind(h1)) {
|
||||
if(sphere) {
|
||||
for(int i=0; i<3; i++) h1[i] = -h1[i];
|
||||
poly_flags &= ~POLY_CENTERIN;
|
||||
}
|
||||
else
|
||||
nofill = true;
|
||||
}
|
||||
applymodel(h1, hscr); hscr[0] *= vid.radius; hscr[1] *= vid.radius * vid.stretch;
|
||||
for(int i=0; i<isize(glcoords)-1; i++) {
|
||||
double x1 = glcoords[i][0] - hscr[0];
|
||||
double y1 = glcoords[i][1] - hscr[1];
|
||||
double x2 = glcoords[i+1][0] - hscr[0];
|
||||
double y2 = glcoords[i+1][1] - hscr[1];
|
||||
if(asign(y1, y2)) {
|
||||
ld x = xcross(x1, y1, x2, y2);
|
||||
if(x < -1e-6) poly_flags ^= POLY_CENTERIN;
|
||||
else if (x < 1e-6) nofill = true;
|
||||
}
|
||||
}
|
||||
|
||||
poly_flags &= ~POLY_INVERSE;
|
||||
if(poly_flags & POLY_CENTERIN) {
|
||||
poly_flags |= POLY_INVERSE;
|
||||
/* nofill = true;
|
||||
outline = (flags & POLY_CENTERIN) ? 0x00FF00FF : 0xFF0000FF;
|
||||
addpoint(hscr); */
|
||||
}
|
||||
|
||||
/*
|
||||
if(poly_flags & POLY_BADCENTERIN) {
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0]+10, hscr[1]*vid.stretch, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0], hscr[1]*vid.stretch+10, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0]-10, hscr[1]*vid.stretch, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0], hscr[1]*vid.stretch-10, hscr[2]));
|
||||
glcoords.push_back(make_array<GLfloat>(hscr[0]+10, hscr[1]*vid.stretch, hscr[2]));
|
||||
} */
|
||||
}
|
||||
|
||||
if(!tinf)
|
||||
compute_side_by_centerin(this, nofill);
|
||||
|
||||
else {
|
||||
|
||||
double rarea = 0;
|
||||
for(int i=0; i<isize(glcoords)-1; i++)
|
||||
rarea += glcoords[i][0] * glcoords[i+1][1] - glcoords[i][1] * glcoords[i+1][0];
|
||||
rarea += glcoords.back()[0] * glcoords[0][1] - glcoords.back()[1] * glcoords[0][0];
|
||||
|
||||
if(d < 0) poly_flags ^= POLY_INVERSE;
|
||||
|
||||
if(rarea>0)
|
||||
poly_flags ^= POLY_INVERSE;
|
||||
if(d < 0) poly_flags ^= POLY_INVERSE;
|
||||
compute_side_by_area();
|
||||
}
|
||||
|
||||
if(poly_flags & POLY_INVERSE) {
|
||||
if(curradius < vid.alpha - 1e-6) return;
|
||||
if(!sphere) return;
|
||||
}
|
||||
|
||||
}
|
||||
else poly_flags &=~ POLY_INVERSE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user