rug:: conformal tori
This commit is contained in:
parent
9736068810
commit
886d9d1619
|
@ -39,7 +39,7 @@ EX bool non_spatial_model() {
|
||||||
return pmodel && vid.consider_shader_projection && (get_shader_flags() & SF_DIRECT);
|
return pmodel && vid.consider_shader_projection && (get_shader_flags() & SF_DIRECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
hyperpoint perspective_to_space(hyperpoint h, ld alpha, eGeometryClass gc) {
|
EX hyperpoint perspective_to_space(hyperpoint h, ld alpha, eGeometryClass gc) {
|
||||||
ld hx = h[0], hy = h[1];
|
ld hx = h[0], hy = h[1];
|
||||||
|
|
||||||
if(gc == gcEuclid)
|
if(gc == gcEuclid)
|
||||||
|
|
33
rug.cpp
33
rug.cpp
|
@ -439,7 +439,7 @@ EX void buildTorusRug() {
|
||||||
hyperpoint yh = euc::eumove(p2)*C0-C0;
|
hyperpoint yh = euc::eumove(p2)*C0-C0;
|
||||||
if(nonorientable) yh *= 2;
|
if(nonorientable) yh *= 2;
|
||||||
|
|
||||||
bool flipped = sqhypot_d(2, xh) < sqhypot_d(2, yh);
|
bool flipped = false; // sqhypot_d(2, xh) < sqhypot_d(2, yh);
|
||||||
|
|
||||||
if(flipped) swap(xh, yh);
|
if(flipped) swap(xh, yh);
|
||||||
|
|
||||||
|
@ -461,6 +461,12 @@ EX void buildTorusRug() {
|
||||||
|
|
||||||
map<pair<int, int>, rugpoint*> glues;
|
map<pair<int, int>, rugpoint*> glues;
|
||||||
|
|
||||||
|
ld mx = 0;
|
||||||
|
for(int i=0; i<1000; i++)
|
||||||
|
mx = max(mx, hypot(xfactor, yfactor * sin(i)) / (1-yfactor * cos(i)));
|
||||||
|
|
||||||
|
println(hlog, "mx = ", mx);
|
||||||
|
|
||||||
auto addToruspoint = [&] (hyperpoint h) {
|
auto addToruspoint = [&] (hyperpoint h) {
|
||||||
auto r = addRugpoint(C0, 0);
|
auto r = addRugpoint(C0, 0);
|
||||||
hyperpoint onscreen;
|
hyperpoint onscreen;
|
||||||
|
@ -472,14 +478,25 @@ EX void buildTorusRug() {
|
||||||
double alpha = -h[0] * 2 * M_PI;
|
double alpha = -h[0] * 2 * M_PI;
|
||||||
double beta = h[1] * 2 * M_PI;
|
double beta = h[1] * 2 * M_PI;
|
||||||
|
|
||||||
if(gwhere == gSphere) {
|
ld ax = alpha + 1.124651, bx = beta + 1.214893;
|
||||||
ld ax = alpha + 1.124651, bx = beta + 1.214893;
|
ld x = xfactor * sin(ax), y = xfactor * cos(ax), z = yfactor * sin(bx), t = yfactor * cos(bx);
|
||||||
ld x = xfactor * sin(ax), y = xfactor * cos(ax), z = yfactor * sin(bx), t = yfactor * cos(bx);
|
|
||||||
ld d = acos(t) / sqrt(x*x+y*y+z*z);
|
ld d;
|
||||||
r->flat = r->h = hpxyz(x * d, y * d, z * d);
|
ld hxyz = sqrt(x*x+y*y+z*z);
|
||||||
|
|
||||||
|
if(gwhere == gNormal) {
|
||||||
|
d = hxyz / (1-t) / mx;
|
||||||
|
d *= .95;
|
||||||
|
hyperpoint test = hpxy(d, 0);
|
||||||
|
test = perspective_to_space(test, 1, gcHyperbolic);
|
||||||
|
d = acosh(test[2]) / hxyz;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
r->flat = r->h = modelscale * hpxyz((xfactor+yfactor*cos(beta)) * cos(alpha), (xfactor+yfactor*cos(beta)) * sin(alpha), yfactor*-sin(beta));
|
d = (gwhere == gSphere) ? acos(t) / hxyz : modelscale * 3 / (1-t) / mx;
|
||||||
|
}
|
||||||
|
|
||||||
|
r->flat = r->h = hpxyz(x*d, y*d, z*d);
|
||||||
|
|
||||||
r->valid = true;
|
r->valid = true;
|
||||||
|
|
||||||
static const int X = 100003; // a prime
|
static const int X = 100003; // a prime
|
||||||
|
|
Loading…
Reference in New Issue