mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-27 06:27:17 +00:00
small_hyperboloid more universal
This commit is contained in:
parent
90b416f594
commit
be949b3698
20
drawing.cpp
20
drawing.cpp
@ -353,7 +353,8 @@ EX int get_side(const hyperpoint& H) {
|
||||
if(pmodel == mdRotatedHyperboles)
|
||||
return H[1] > 0 ? -1 : 1;
|
||||
if(pmodel == mdHyperboloid) {
|
||||
return det2(pconf.ball() * cspin90(2, 1) * rgpushxto0(H)) > 0 ? 1 : -1;
|
||||
auto H1 = H; if(sphere && pconf.small_hyperboloid) H1 = mid(H, C0);
|
||||
return det2(pconf.ball() * cspin90(2, 1) * rgpushxto0(H1)) > 0 ? 1 : -1;
|
||||
}
|
||||
if(pmodel == mdHyperboloidFlat && sphere)
|
||||
return H[2] >= 0 ? 1 : -1;
|
||||
@ -364,6 +365,7 @@ EX int get_side(const hyperpoint& H) {
|
||||
}
|
||||
if(pmodel == mdHemisphere && sphere) {
|
||||
auto H1 = H;
|
||||
if(pconf.small_hyperboloid) H1 = mid(H, C0);
|
||||
int s = H1[2] > 0 ? 1 : -1;
|
||||
if(hemi_side && s != hemi_side) return -spherespecial;
|
||||
H1[0] /= H1[2]; H1[1] /= H1[2];
|
||||
@ -570,6 +572,16 @@ void addpoly(const shiftmatrix& V, const vector<glvertex> &tab, int ofs, int cnt
|
||||
|
||||
for(auto& p: tofix)
|
||||
fixpoint(glcoords[p.first], p.second);
|
||||
|
||||
if(sphere && among(pmodel, mdHemisphere, mdHyperboloid) && pconf.small_hyperboloid) {
|
||||
bool left = false, right = false;
|
||||
for(auto h: glcoords) { hyperpoint h1; applymodel(shiftless(glhr::gltopoint(h)), h1);
|
||||
if(h1[0] < -0) left = true;
|
||||
if(h1[0] > +0) right = true;
|
||||
}
|
||||
if(left && right) poly_flags |= POLY_NIF_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
hyperpoint Hscr;
|
||||
applymodel(goodpoint, Hscr);
|
||||
@ -2016,6 +2028,8 @@ void dqi_poly::draw() {
|
||||
if(pmodel == mdDisk && hyperbolic && pconf.alpha <= -1) can_have_inverse = true;
|
||||
if(pmodel == mdSpiral && pconf.skiprope) can_have_inverse = true;
|
||||
if(pmodel == mdCentralInversion) can_have_inverse = true;
|
||||
|
||||
if(among(pmodel, mdHemisphere, mdHyperboloid) && sphere && pconf.small_hyperboloid) can_have_inverse = true;
|
||||
|
||||
if(can_have_inverse && !(poly_flags & POLY_ISSIDE)) {
|
||||
|
||||
@ -2035,6 +2049,8 @@ void dqi_poly::draw() {
|
||||
|
||||
}
|
||||
else poly_flags &=~ POLY_INVERSE;
|
||||
|
||||
if(among(pmodel, mdHemisphere, mdHyperboloid) && sphere && pconf.small_hyperboloid && (poly_flags & POLY_INVERSE)) return;
|
||||
|
||||
if(spherespecial) {
|
||||
if(!(poly_flags & POLY_INFRONT)) return;
|
||||
@ -2433,7 +2449,7 @@ EX void draw_main() {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pmodel == mdHemisphere && sphere && hemi_side == 0 && !vrhr::rendering()) {
|
||||
if(pmodel == mdHemisphere && sphere && hemi_side == 0 && !vrhr::rendering() && !pconf.small_hyperboloid) {
|
||||
hemi_side = (pconf.ball() * hyperpoint(0,1,0,1)) [2] < 0 ? 1 : -1;
|
||||
draw_main();
|
||||
|
||||
|
@ -925,6 +925,7 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
|
||||
|
||||
switch(cgclass) {
|
||||
case gcHyperbolic: {
|
||||
if(pconf.small_hyperboloid) H = mid(C0, H);
|
||||
ld zl = zlevel(H);
|
||||
ret = H / H[2];
|
||||
ret[2] = sqrt(1 - sqhypot_d(2, ret));
|
||||
@ -944,11 +945,13 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
|
||||
ret[2] = (1 - y);
|
||||
ret[2] *= dir;
|
||||
ret = ret * (1 + (H[2]-1) * y * pconf.depth_scaling * dir / pconf.euclid_to_sphere);
|
||||
if(pconf.small_hyperboloid) { ret = ret - C0; ret = ret / hypot_d(3, ret); }
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case gcSphere: {
|
||||
if(pconf.small_hyperboloid) H = mid(C0, H);
|
||||
if(vrhr::rendering()) { vr_sphere(ret, H, md); return; }
|
||||
ld z = sqhypot_d(3, H);
|
||||
int s = H[2] > 0 ? 1 : -1;
|
||||
|
10
models.cpp
10
models.cpp
@ -425,6 +425,7 @@ EX namespace models {
|
||||
USING_NATIVE_GEOMETRY_IN_RUG;
|
||||
#endif
|
||||
dialog::init(XLAT("models & projections"));
|
||||
mouseovers = XLAT("see http://www.roguetemple.com/z/hyper/models.php");
|
||||
|
||||
auto vpmodel = vpconf.model;
|
||||
|
||||
@ -626,10 +627,11 @@ EX namespace models {
|
||||
add_edit(vpconf.fisheye_alpha);
|
||||
}
|
||||
|
||||
if(is_hyperboloid(vpmodel)) {
|
||||
if(is_hyperboloid(vpmodel))
|
||||
add_edit(pconf.show_hyperboloid_flat);
|
||||
|
||||
if(among(vpmodel, mdHyperboloid, mdHemisphere))
|
||||
add_edit(pconf.small_hyperboloid);
|
||||
}
|
||||
|
||||
if(vpmodel == mdCollignon)
|
||||
add_edit(vpconf.collignon_parameter);
|
||||
@ -1045,8 +1047,8 @@ EX namespace models {
|
||||
-> editable("show flat", 'b');
|
||||
|
||||
param_b(p.small_hyperboloid, sp+"hyperboloid-small", false)
|
||||
-> editable("small hyperboloid model", 't')
|
||||
-> help("as in Clifford algebras");
|
||||
-> editable("halve distances", 'h')
|
||||
-> help("This option halves the distances of every point from the center. Useful in the Minkowski hyperboloid model, to get a visualization of an alternative hyperboloid model based on Clifford algebras.");
|
||||
|
||||
param_f(p.skiprope, sp+"mobius", 0)
|
||||
-> editable(0, 360, 15, "Möbius transformations", "", 'S')->unit = "°";
|
||||
|
Loading…
Reference in New Issue
Block a user