1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 09:30:35 +00:00

axial angle now can be set for axial models

This commit is contained in:
Zeno Rogue 2023-03-16 23:13:27 +01:00
parent 631e44f871
commit a434f3b063
2 changed files with 54 additions and 37 deletions

View File

@ -501,6 +501,33 @@ EX void threepoint_projection(const hyperpoint& H, hyperpoint& ret) {
EX vector<hr::function<void(shiftpoint& H_orig, hyperpoint& H, hyperpoint& ret)>> extra_projections;
EX void make_axial(hyperpoint H, hyperpoint& ret, const hr::function<ld(hyperpoint)>& f) {
models::apply_orientation_yz(H[1], H[2]);
models::apply_orientation(H[0], H[1]);
ret[0] = f(H);
ld axi = pconf.axial_angle;
bool ax = GDIM == 3 || (axi/180 - floor(axi/180)) == 0.5;
if(ax) {
ret[1] = f(cspin90(0, 1) * H);
ret[2] = 0;
if(GDIM == 3) ret[2] = f(cspin90(2, 1) * H);
}
else {
ld alpha = axi * degree;
ld val = f(cspin(0, 1, alpha) * H);
// ret[0] * cos(alpha) + ret[1] * sin(alpha) == val
ret[1] = (val - ret[0] * cos(alpha)) / sin(alpha);
ret[2] = 0;
}
ret[3] = 1;
models::apply_orientation(ret[1], ret[0]);
models::apply_orientation_yz(ret[2], ret[1]);
}
EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
hyperpoint H = H_orig.h;
@ -680,48 +707,31 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
ret[1] += height * pconf.depth_scaling;
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;
}
case mdAxial: {
make_axial(H, ret, [] (hyperpoint H) {
ld& mt = pconf.model_transition;
ld z = H[LDIM];
if(mt != 1) z += (1-mt) * pconf.alpha;
ld res = H[0] / z;
if(mt) {
if(mt < 1) res *= mt;
res = atan_auto(res * mt);
if(mt > 1) res /= mt;
}
return res;
});
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]);
make_axial(H, ret, [] (hyperpoint H) { return asin_auto(H[0]); });
break;
}

View File

@ -627,6 +627,9 @@ EX namespace models {
if(mdinf[vpmodel].flags & mf::twopoint)
add_edit(vpconf.twopoint_param);
if(mdinf[vpmodel].flags & mf::axial)
add_edit(vpconf.axial_angle);
if(vpmodel == mdFisheye)
add_edit(vpconf.fisheye_param);
@ -1001,8 +1004,12 @@ EX namespace models {
param_f(p.twopoint_param, pp+"twopoint", sp+"twopoint parameter", 1)
-> editable(1e-3, 10, .1, "two-point parameter", "In two-point-based models, this parameter gives the distance from each of the two points to the center.", 'b')
-> set_sets(dialog::scaleLog)
;
-> set_sets(dialog::scaleLog);
param_f(p.axial_angle, pp+"axial", sp+"axial angle", 90)
-> editable(1e-3, 10, .1, "angle between the axes", "In two-axe-based models, this parameter gives the angle between the two axes.", 'x')
-> set_sets(dialog::scaleLog);
param_f(p.fisheye_param, pp+"fisheye", sp+"fisheye parameter", 1)
-> editable(1e-3, 10, .1, "fisheye parameter", "Size of the fish eye.", 'b')
-> set_sets(dialog::scaleLog);