mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 01:20:37 +00:00
three new projections
This commit is contained in:
parent
c9e0529a88
commit
64cb6772e8
@ -973,8 +973,8 @@ enum eModel : int {
|
|||||||
// 20..24
|
// 20..24
|
||||||
mdEquivolume, mdCentralInversion, mdSimulatedPerspective, mdTwoHybrid, mdGeodesic,
|
mdEquivolume, mdCentralInversion, mdSimulatedPerspective, mdTwoHybrid, mdGeodesic,
|
||||||
// 25
|
// 25
|
||||||
mdMollweide, mdCentralCyl, mdCollignon, mdHorocyclic,
|
mdMollweide, mdCentralCyl, mdCollignon, mdHorocyclic, mdQuadrant, mdAxial, mdAntiAxial,
|
||||||
// 29..
|
// 32..
|
||||||
mdGUARD, mdPixel, mdHyperboloidFlat, mdPolynomial, mdManual
|
mdGUARD, mdPixel, mdHyperboloidFlat, mdPolynomial, mdManual
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@ -1016,6 +1016,9 @@ EX vector<modelinfo> mdinf = {
|
|||||||
{X3("central cylindrical"), mf::euc_boring | mf::band, DEFAULTS},
|
{X3("central cylindrical"), mf::euc_boring | mf::band, DEFAULTS},
|
||||||
{X3("Collignon"), mf::pseudoband | mf::equiarea, DEFAULTS},
|
{X3("Collignon"), mf::pseudoband | mf::equiarea, DEFAULTS},
|
||||||
{X3("horocyclic coordinates"), mf::euc_boring, DEFAULTS},
|
{X3("horocyclic coordinates"), mf::euc_boring, DEFAULTS},
|
||||||
|
{X3("quadrant coordinates"), mf::euc_boring, DEFAULTS},
|
||||||
|
{X3("axial coordinates"), mf::euc_boring, DEFAULTS},
|
||||||
|
{X3("anti-axial coordinates"), mf::euc_boring, DEFAULTS},
|
||||||
{X3("guard"), 0, DEFAULTS},
|
{X3("guard"), 0, DEFAULTS},
|
||||||
{X3("polynomial"), mf::conformal, DEFAULTS},
|
{X3("polynomial"), mf::conformal, DEFAULTS},
|
||||||
};
|
};
|
||||||
|
17
drawing.cpp
17
drawing.cpp
@ -262,14 +262,19 @@ void add1(const hyperpoint& H) {
|
|||||||
glcoords.push_back(glhr::pointtogl(H));
|
glcoords.push_back(glhr::pointtogl(H));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int axial_sign() {
|
||||||
|
return ((axial_x ^ axial_y)&1) ? -1:1;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_behind(const hyperpoint& H) {
|
bool is_behind(const hyperpoint& H) {
|
||||||
|
if(pmodel == mdAxial && sphere) return axial_sign() * H[2] <= BEHIND_LIMIT;
|
||||||
return pmodel == mdDisk && (hyperbolic ? H[2] >= 0 : true) && (nonisotropic ? false : pconf.alpha + H[2] <= BEHIND_LIMIT);
|
return pmodel == mdDisk && (hyperbolic ? H[2] >= 0 : true) && (nonisotropic ? false : pconf.alpha + H[2] <= BEHIND_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
hyperpoint be_just_on_view(const hyperpoint& H1, const hyperpoint &H2) {
|
hyperpoint be_just_on_view(const hyperpoint& H1, const hyperpoint &H2) {
|
||||||
// H1[2] * t + H2[2] * (1-t) == BEHIND_LIMIT - pconf.alpha
|
// H1[2] * t + H2[2] * (1-t) == BEHIND_LIMIT - pconf.alpha
|
||||||
// H2[2]- BEHIND_LIMIT + pconf.alpha = t * (H2[2] - H1[2])
|
// H2[2]- BEHIND_LIMIT + pconf.alpha = t * (H2[2] - H1[2])
|
||||||
ld t = (H2[2] - BEHIND_LIMIT + pconf.alpha) / (H2[2] - H1[2]);
|
ld t = (axial_sign() * H2[2] - BEHIND_LIMIT + (pmodel == mdAxial ? 0 : pconf.alpha)) / (H2[2] - H1[2]) * axial_sign();
|
||||||
return H1 * t + H2 * (1-t);
|
return H1 * t + H2 * (1-t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2136,6 +2141,16 @@ EX void draw_main() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else if(pmodel == mdAxial && sphere) {
|
||||||
|
for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE)
|
||||||
|
ptd->draw();
|
||||||
|
for(axial_x=-4; axial_x<=4; axial_x++)
|
||||||
|
for(axial_y=-4; axial_y<=4; axial_y++)
|
||||||
|
for(auto& ptd: ptds) if(ptd->prio != PPR::OUTCIRCLE) {
|
||||||
|
ptd->draw();
|
||||||
|
}
|
||||||
|
glflush();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
DEBB(DF_GRAPH, ("draw_main1"));
|
DEBB(DF_GRAPH, ("draw_main1"));
|
||||||
if(ray::in_use && !ray::comparison_mode) {
|
if(ray::in_use && !ray::comparison_mode) {
|
||||||
|
69
hypgraph.cpp
69
hypgraph.cpp
@ -343,6 +343,8 @@ hyperpoint compute_hybrid(hyperpoint H, int rootid) {
|
|||||||
|
|
||||||
EX ld signed_sqrt(ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); }
|
EX ld signed_sqrt(ld x) { return x > 0 ? sqrt(x) : -sqrt(-x); }
|
||||||
|
|
||||||
|
EX int axial_x, axial_y;
|
||||||
|
|
||||||
EX void applymodel(shiftpoint H_orig, hyperpoint& ret) {
|
EX void applymodel(shiftpoint H_orig, hyperpoint& ret) {
|
||||||
|
|
||||||
hyperpoint H = H_orig.h;
|
hyperpoint H = H_orig.h;
|
||||||
@ -486,6 +488,73 @@ EX void applymodel(shiftpoint H_orig, hyperpoint& ret) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case mdAxial: {
|
||||||
|
models::apply_orientation_yz(H[1], H[2]);
|
||||||
|
models::apply_orientation(H[0], H[1]);
|
||||||
|
|
||||||
|
ld& mt = pconf.model_transition;
|
||||||
|
|
||||||
|
ld z = H[LDIM];
|
||||||
|
if(mt != 1) z += (1-mt) * pconf.alpha;
|
||||||
|
|
||||||
|
ret[0] = H[0] / z;
|
||||||
|
ret[1] = H[1] / z;
|
||||||
|
if(GDIM == 3) ret[2] = H[2] / z;
|
||||||
|
else ret[2] = 0;
|
||||||
|
ret[3] = 1;
|
||||||
|
|
||||||
|
if(mt) for(int i=0; i<LDIM; i++) {
|
||||||
|
if(mt < 1)
|
||||||
|
ret[i] *= mt;
|
||||||
|
ret[i] = atan_auto(ret[i]);
|
||||||
|
if(mt < 1)
|
||||||
|
ret[i] /= mt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sphere) ret[0] += axial_x * M_PI, ret[1] += axial_y * M_PI;
|
||||||
|
|
||||||
|
models::apply_orientation(ret[1], ret[0]);
|
||||||
|
models::apply_orientation_yz(ret[2], ret[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case mdAntiAxial: {
|
||||||
|
models::apply_orientation_yz(H[1], H[2]);
|
||||||
|
models::apply_orientation(H[0], H[1]);
|
||||||
|
|
||||||
|
ret[0] = asin_auto(H[0]);
|
||||||
|
ret[1] = asin_auto(H[1]);
|
||||||
|
|
||||||
|
ret[2] = 0; ret[3] = 1;
|
||||||
|
|
||||||
|
models::apply_orientation(ret[1], ret[0]);
|
||||||
|
models::apply_orientation_yz(ret[2], ret[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case mdQuadrant: {
|
||||||
|
H = space_to_perspective(H);
|
||||||
|
models::apply_orientation_yz(H[1], H[2]);
|
||||||
|
models::apply_orientation(H[0], H[1]);
|
||||||
|
|
||||||
|
tie(H[0], H[1]) = make_pair((H[0] + H[1]) / sqrt(2), (H[1] - H[0]) / sqrt(2));
|
||||||
|
|
||||||
|
H[1] += 1;
|
||||||
|
double rad = sqhypot_d(GDIM, H);
|
||||||
|
H /= -rad;
|
||||||
|
H[1] += .5;
|
||||||
|
|
||||||
|
H *= 2;
|
||||||
|
|
||||||
|
ld x = exp(-H[0]/2);
|
||||||
|
ret[0] = -H[1] * x - 1;
|
||||||
|
ret[1] = H[1] / x + 1;
|
||||||
|
|
||||||
|
models::apply_orientation(ret[1], ret[0]);
|
||||||
|
models::apply_orientation_yz(ret[2], ret[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case mdHorocyclic: {
|
case mdHorocyclic: {
|
||||||
|
|
||||||
find_zlev(H);
|
find_zlev(H);
|
||||||
|
@ -205,7 +205,7 @@ EX namespace models {
|
|||||||
|
|
||||||
EX bool has_orientation(eModel m) {
|
EX bool has_orientation(eModel m) {
|
||||||
return
|
return
|
||||||
among(m, mdHalfplane, mdPolynomial, mdPolygonal, mdTwoPoint, mdJoukowsky, mdJoukowskyInverted, mdSpiral, mdSimulatedPerspective, mdTwoHybrid, mdHorocyclic) || mdBandAny();
|
among(m, mdHalfplane, mdPolynomial, mdPolygonal, mdTwoPoint, mdJoukowsky, mdJoukowskyInverted, mdSpiral, mdSimulatedPerspective, mdTwoHybrid, mdHorocyclic, mdAxial, mdAntiAxial, mdQuadrant) || mdBandAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
EX bool is_perspective(eModel m) {
|
EX bool is_perspective(eModel m) {
|
||||||
@ -218,7 +218,7 @@ EX namespace models {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EX bool has_transition(eModel m) {
|
EX bool has_transition(eModel m) {
|
||||||
return among(m, mdJoukowsky, mdJoukowskyInverted, mdBand) && GDIM == 2;
|
return among(m, mdJoukowsky, mdJoukowskyInverted, mdBand, mdAxial) && GDIM == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX bool product_model(eModel m) {
|
EX bool product_model(eModel m) {
|
||||||
|
Loading…
Reference in New Issue
Block a user