mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 18:00:34 +00:00
spiral projection generalized
This commit is contained in:
parent
4284831069
commit
fd5dfd6b39
@ -424,6 +424,8 @@ namespace conformal {
|
|||||||
|
|
||||||
cld spiral_multiplier;
|
cld spiral_multiplier;
|
||||||
ld right_spiral_multiplier = 1;
|
ld right_spiral_multiplier = 1;
|
||||||
|
ld any_spiral_multiplier = 1;
|
||||||
|
ld sphere_spiral_multiplier = 2;
|
||||||
ld spiral_cone = 360;
|
ld spiral_cone = 360;
|
||||||
ld spiral_cone_rad;
|
ld spiral_cone_rad;
|
||||||
bool ring_not_spiral;
|
bool ring_not_spiral;
|
||||||
@ -439,19 +441,18 @@ namespace conformal {
|
|||||||
model_straight_yz = DIM == 2 || (ocos_yz > 1-1e-9);
|
model_straight_yz = DIM == 2 || (ocos_yz > 1-1e-9);
|
||||||
if(conformal::on) conformal::apply();
|
if(conformal::on) conformal::apply();
|
||||||
|
|
||||||
if(hyperbolic) {
|
if(!euclid) {
|
||||||
ld b = spiral_angle * degree;
|
ld b = spiral_angle * degree;
|
||||||
ld cos_spiral = cos(b);
|
ld cos_spiral = cos(b);
|
||||||
ld sin_spiral = sin(b);
|
ld sin_spiral = sin(b);
|
||||||
spiral_cone_rad = spiral_cone * degree;
|
spiral_cone_rad = spiral_cone * degree;
|
||||||
ring_not_spiral = abs(cos_spiral) < 1e-3;
|
ring_not_spiral = abs(cos_spiral) < 1e-3;
|
||||||
if(ring_not_spiral) {
|
ld mul = 1;
|
||||||
cos_spiral = 0;
|
if(sphere) mul = .5 * sphere_spiral_multiplier;
|
||||||
sin_spiral = 1;
|
else if(ring_not_spiral) mul = right_spiral_multiplier;
|
||||||
spiral_multiplier = cld(0, right_spiral_multiplier * spiral_cone_rad / 2);
|
else mul = any_spiral_multiplier * cos_spiral;
|
||||||
}
|
|
||||||
else
|
spiral_multiplier = cld(cos_spiral, sin_spiral) * cld(spiral_cone_rad * mul / 2., 0);
|
||||||
spiral_multiplier = cld(cos_spiral, sin_spiral) * cld(spiral_cone_rad * cos_spiral / 2., 0);
|
|
||||||
}
|
}
|
||||||
if(euclid) {
|
if(euclid) {
|
||||||
hyperpoint h = tC0(eumove(spiral_x, spiral_y));
|
hyperpoint h = tC0(eumove(spiral_x, spiral_y));
|
||||||
@ -908,18 +909,28 @@ namespace conformal {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pmodel == mdSpiral && hyperbolic) {
|
if(pmodel == mdSpiral && !euclid) {
|
||||||
dialog::addSelItem(XLAT("spiral angle"), fts(spiral_angle), 'x');
|
dialog::addSelItem(XLAT("spiral angle"), fts(spiral_angle), 'x');
|
||||||
dialog::add_action([](){
|
dialog::add_action([](){
|
||||||
dialog::editNumber(spiral_angle, 0, 360, 15, 0, XLAT("spiral angle"), "");
|
dialog::editNumber(spiral_angle, 0, 360, 15, 0, XLAT("spiral angle"), "");
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ring_not_spiral) {
|
ld& which =
|
||||||
dialog::addSelItem(XLAT("spiral multiplier"), fts(right_spiral_multiplier), 'M');
|
sphere ? sphere_spiral_multiplier :
|
||||||
dialog::add_action([](){
|
ring_not_spiral ? right_spiral_multiplier :
|
||||||
dialog::editNumber(right_spiral_multiplier, 0, 10, -.1, 1, XLAT("spiral multiplier"), "");
|
any_spiral_multiplier;
|
||||||
|
|
||||||
|
dialog::addSelItem(XLAT("spiral multiplier"), fts(which), 'M');
|
||||||
|
dialog::add_action([&which](){
|
||||||
|
dialog::editNumber(which, 0, 10, -.1, 1, XLAT("spiral multiplier"),
|
||||||
|
XLAT(
|
||||||
|
"This parameter has a bit different scale depending on the settings:\n"
|
||||||
|
"(1) in spherical geometry (with spiral angle=90, 1 produces a stereographic projection)\n"
|
||||||
|
"(2) in hyperbolic geometry, with spiral angle being +90° or -90°\n"
|
||||||
|
"(3) in hyperbolic geometry, with other spiral angles (1 makes the bands fit exactly)"
|
||||||
|
)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
dialog::addSelItem(XLAT("spiral cone"), fts(spiral_cone), 'C');
|
dialog::addSelItem(XLAT("spiral cone"), fts(spiral_cone), 'C');
|
||||||
dialog::add_action([](){
|
dialog::add_action([](){
|
||||||
@ -1225,9 +1236,14 @@ namespace conformal {
|
|||||||
else if(argis("-sang")) {
|
else if(argis("-sang")) {
|
||||||
PHASEFROM(2);
|
PHASEFROM(2);
|
||||||
shift_arg_formula(conformal::spiral_angle);
|
shift_arg_formula(conformal::spiral_angle);
|
||||||
if(conformal::spiral_angle == 90) {
|
if(sphere)
|
||||||
|
shift_arg_formula(conformal::sphere_spiral_multiplier);
|
||||||
|
else if(conformal::spiral_angle == 90)
|
||||||
shift_arg_formula(conformal::right_spiral_multiplier);
|
shift_arg_formula(conformal::right_spiral_multiplier);
|
||||||
}
|
}
|
||||||
|
else if(argis("-ssm")) {
|
||||||
|
PHASEFROM(2);
|
||||||
|
shift_arg_formula(conformal::any_spiral_multiplier);
|
||||||
}
|
}
|
||||||
else if(argis("-scone")) {
|
else if(argis("-scone")) {
|
||||||
PHASEFROM(2);
|
PHASEFROM(2);
|
||||||
|
42
hypgraph.cpp
42
hypgraph.cpp
@ -192,11 +192,12 @@ template<class T> void makeband(hyperpoint H, hyperpoint& ret, const T& f) {
|
|||||||
|
|
||||||
ld x, y, yf, zf=0;
|
ld x, y, yf, zf=0;
|
||||||
y = asin_auto(H[1]);
|
y = asin_auto(H[1]);
|
||||||
x = asin_auto_clamp(H[0] / cos_auto(y)) + band_shift;
|
x = asin_auto_clamp(H[0] / cos_auto(y));
|
||||||
if(sphere) {
|
if(sphere) {
|
||||||
if(H[DIM] < 0 && x > 0) x = M_PI - x;
|
if(H[DIM] < 0 && x > 0) x = M_PI - x;
|
||||||
else if(H[DIM] < 0 && x <= 0) x = -M_PI - x;
|
else if(H[DIM] < 0 && x <= 0) x = -M_PI - x;
|
||||||
}
|
}
|
||||||
|
x += band_shift;
|
||||||
hypot_zlev(zlev, y, yf, zf);
|
hypot_zlev(zlev, y, yf, zf);
|
||||||
|
|
||||||
f(x, y);
|
f(x, y);
|
||||||
@ -628,7 +629,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) {
|
|||||||
|
|
||||||
case mdSpiral: {
|
case mdSpiral: {
|
||||||
cld z;
|
cld z;
|
||||||
if(hyperbolic) makeband(H, ret, band_conformal);
|
if(hyperbolic || sphere) makeband(H, ret, band_conformal);
|
||||||
else ret = H;
|
else ret = H;
|
||||||
z = cld(ret[0], ret[1]) * conformal::spiral_multiplier;
|
z = cld(ret[0], ret[1]) * conformal::spiral_multiplier;
|
||||||
|
|
||||||
@ -910,7 +911,33 @@ void drawrec(cell *c, const transmatrix& V) {
|
|||||||
|
|
||||||
vector<tuple<heptspin, hstate, transmatrix, ld> > drawn_cells;
|
vector<tuple<heptspin, hstate, transmatrix, ld> > drawn_cells;
|
||||||
|
|
||||||
|
bool in_multi = false;
|
||||||
|
|
||||||
void hrmap_standard::draw() {
|
void hrmap_standard::draw() {
|
||||||
|
if(sphere && pmodel == mdSpiral && !in_multi) {
|
||||||
|
in_multi = true;
|
||||||
|
if(conformal::ring_not_spiral) {
|
||||||
|
int qty = ceil(1. / conformal::sphere_spiral_multiplier);
|
||||||
|
if(qty > 100) qty = 100;
|
||||||
|
for(int i=-qty; i < qty; i++) {
|
||||||
|
band_shift = 2 * M_PI * i;
|
||||||
|
draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
draw();
|
||||||
|
if(vid.use_smart_range) for(int i=1;; i++) {
|
||||||
|
int drawn = cells_drawn;
|
||||||
|
band_shift = 2 * M_PI * i;
|
||||||
|
draw();
|
||||||
|
band_shift = -2 * M_PI * i;
|
||||||
|
draw();
|
||||||
|
if(drawn == cells_drawn) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
in_multi = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
drawn_cells.clear();
|
drawn_cells.clear();
|
||||||
drawn_cells.emplace_back(viewctr, hsOrigin, cview(), band_shift);
|
drawn_cells.emplace_back(viewctr, hsOrigin, cview(), band_shift);
|
||||||
for(int i=0; i<isize(drawn_cells); i++) {
|
for(int i=0; i<isize(drawn_cells); i++) {
|
||||||
@ -973,6 +1000,8 @@ void hrmap_standard::draw() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sphere) draw = true;
|
||||||
|
|
||||||
if(draw) for(int d=0; d<S7; d++) {
|
if(draw) for(int d=0; d<S7; d++) {
|
||||||
hstate s2 = transition(s, d);
|
hstate s2 = transition(s, d);
|
||||||
if(s2 == hsError) continue;
|
if(s2 == hsError) continue;
|
||||||
@ -1556,6 +1585,7 @@ void draw_boundary(int w) {
|
|||||||
case mdSpiral: {
|
case mdSpiral: {
|
||||||
using namespace hyperpoint_vec;
|
using namespace hyperpoint_vec;
|
||||||
if(euclid) return;
|
if(euclid) return;
|
||||||
|
if(conformal::ring_not_spiral) return;
|
||||||
// if(p == PPR::CIRCLE) p = PPR::OUTCIRCLE;
|
// if(p == PPR::CIRCLE) p = PPR::OUTCIRCLE;
|
||||||
auto& sm = conformal::spiral_multiplier;
|
auto& sm = conformal::spiral_multiplier;
|
||||||
ld u = hypot(1, imag(sm) / real(sm));
|
ld u = hypot(1, imag(sm) / real(sm));
|
||||||
@ -1590,13 +1620,17 @@ void draw_boundary(int w) {
|
|||||||
|
|
||||||
ld band_shift = 0;
|
ld band_shift = 0;
|
||||||
void fix_the_band(transmatrix& T) {
|
void fix_the_band(transmatrix& T) {
|
||||||
if((models[pmodel].flags & mf::quasiband) && T[2][2] > 1e6) {
|
if(((models[pmodel].flags & mf::quasiband) && T[DIM][DIM] > 1e6) || (sphere && pmodel == mdSpiral)) {
|
||||||
hyperpoint H = tC0(T);
|
hyperpoint H = tC0(T);
|
||||||
find_zlev(H);
|
find_zlev(H);
|
||||||
conformal::apply_orientation(H[0], H[1]);
|
conformal::apply_orientation(H[0], H[1]);
|
||||||
|
|
||||||
ld y = asin_auto(H[1]);
|
ld y = asin_auto(H[1]);
|
||||||
ld x = asin_auto_clamp(H[0] / cos_auto(y));
|
ld x = asin_auto_clamp(H[0] / cos_auto(y));
|
||||||
|
if(sphere) {
|
||||||
|
if(H[DIM] < 0 && x > 0) x = M_PI - x;
|
||||||
|
else if(H[DIM] < 0 && x <= 0) x = -M_PI - x;
|
||||||
|
}
|
||||||
band_shift += x;
|
band_shift += x;
|
||||||
// printf("fixing with shift = %lf\n", x);
|
// printf("fixing with shift = %lf\n", x);
|
||||||
T = xpush(-x) * T;
|
T = xpush(-x) * T;
|
||||||
@ -1663,7 +1697,7 @@ bool do_draw(cell *c, const transmatrix& T) {
|
|||||||
ld iz = imag(z) + 1.14279e-2; // make it never fall exactly on PI
|
ld iz = imag(z) + 1.14279e-2; // make it never fall exactly on PI
|
||||||
if(iz < -M_PI || iz >= M_PI) return false;
|
if(iz < -M_PI || iz >= M_PI) return false;
|
||||||
}
|
}
|
||||||
if(hyperbolic && pmodel == mdSpiral && conformal::ring_not_spiral) {
|
if(pmodel == mdSpiral && conformal::ring_not_spiral) {
|
||||||
cld z;
|
cld z;
|
||||||
hyperpoint H = tC0(T);
|
hyperpoint H = tC0(T);
|
||||||
hyperpoint ret;
|
hyperpoint ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user