1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-23 13:43:19 +00:00

improved square model in non-hyperbolic geometries

This commit is contained in:
Zeno Rogue 2018-04-23 12:50:51 +02:00
parent e43d630185
commit 39916901ee
4 changed files with 20 additions and 2 deletions

View File

@ -11,7 +11,9 @@ typedef long double precise;
namespace polygonal {
typedef complex<ld> cld;
typedef long double xld;
typedef complex<xld> cld;
int SI = 4;
ld STAR = 0;
@ -66,6 +68,11 @@ namespace polygonal {
}
pair<ld, ld> compute(ld x, ld y, int prec) {
if(x*x+y*y > 1) {
xld r = hypot(x,y);
x /= r;
y /= r;
}
if(pmodel == mdPolynomial) {
cld z(x,y);
cld res (0,0);
@ -92,7 +99,7 @@ namespace polygonal {
for(int r=0; r<=2000; r++) {
cld z = exp(cld(0, 2*M_PI * r / 2000.0));
pair<ld,ld> z2 = compute(real(z), imag(z), deg);
pair<xld,xld> z2 = compute(real(z), imag(z), deg);
hyperpoint h;
h[0] = z2.first * vid.radius;
h[1] = z2.second * vid.radius;

View File

@ -971,6 +971,7 @@ namespace polygonal {
extern int SI;
extern ld STAR;
extern int deg;
typedef long double xld;
extern ld coefr[MSI], coefi[MSI];
extern int maxcoef, coefid;
void solve();

View File

@ -482,6 +482,7 @@ void initAll() {
}
firstland = firstland0;
polygonal::solve();
}
void finishAll() {

View File

@ -476,6 +476,15 @@ ld glhypot2(glvertex a, glvertex b) {
void drawpolyline(polytodraw& p) {
auto& pp = p.u.poly;
if(!hyperbolic && among(pmodel, mdPolygonal, mdPolynomial)) {
bool any = false;
for(int i=0; i<pp.cnt; i++) {
hyperpoint h1 = pp.V * glhr::gltopoint((*pp.tab)[pp.offset+i]);
if(h1[2] > 0) any = true;
}
if(!any) return;
}
if(sphere && pp.tinf && pp.cnt > 3) {
int i = pp.cnt;
pp.cnt = 3;