From a434f3b063dbf280e6ada3f02c665670a8958550 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 16 Mar 2023 23:13:27 +0100 Subject: [PATCH] axial angle now can be set for axial models --- hypgraph.cpp | 80 +++++++++++++++++++++++++++++----------------------- models.cpp | 11 ++++++-- 2 files changed, 54 insertions(+), 37 deletions(-) diff --git a/hypgraph.cpp b/hypgraph.cpp index 6ca91edf..bc891857 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -501,6 +501,33 @@ EX void threepoint_projection(const hyperpoint& H, hyperpoint& ret) { EX vector> extra_projections; +EX void make_axial(hyperpoint H, hyperpoint& ret, const hr::function& 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 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; } diff --git a/models.cpp b/models.cpp index f91a37d0..d581b51b 100644 --- a/models.cpp +++ b/models.cpp @@ -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);