From 01a2f0cc5a64a3487c7b14cd6b14a25984e95a4f Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 20 Mar 2019 18:32:03 +0100 Subject: [PATCH] 3d:: change model orientation in the YZ plane --- config.cpp | 1 + conformal.cpp | 20 +++++++++++++++++--- hyper.h | 8 +++++--- hypgraph.cpp | 16 ++++++++++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/config.cpp b/config.cpp index a4364489..96f51552 100644 --- a/config.cpp +++ b/config.cpp @@ -226,6 +226,7 @@ void initConfig() { addsaver(conformal::rotation, "conformal rotation"); addsaver(conformal::do_rotate, "conformal rotation mode", 1); addsaver(conformal::model_orientation, "model orientation", 0); + addsaver(conformal::model_orientation_yz, "model orientation-yz", 0); addsaver(conformal::top_z, "topz", 5); addsaver(conformal::model_transition, "model transition", 1); addsaver(conformal::halfplane_scale, "halfplane scale", 1); diff --git a/conformal.cpp b/conformal.cpp index 7a25389e..8d5d4330 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -274,10 +274,10 @@ namespace conformal { int bandsegment = 16000; ld rotation = 0; int do_rotate = 1; - ld model_orientation, halfplane_scale; - ld ocos, osin; + ld model_orientation, halfplane_scale, model_orientation_yz; + ld ocos, osin, ocos_yz, osin_yz; ld cos_ball, sin_ball; - bool model_straight; + bool model_straight, model_straight_yz; ld top_z = 5; ld model_transition = 1; @@ -402,7 +402,10 @@ namespace conformal { cos_ball = cos(ball), sin_ball = sin(ball); ocos = cos(model_orientation * degree); osin = sin(model_orientation * degree); + ocos_yz = cos(model_orientation_yz * degree); + osin_yz = sin(model_orientation_yz * degree); model_straight = (ocos > 1 - 1e-9); + model_straight_yz = DIM == 2 || (ocos_yz > 1-1e-9); if(conformal::on) conformal::apply(); if(hyperbolic) { @@ -721,6 +724,12 @@ namespace conformal { dialog::add_action([] () { dialog::editNumber(model_orientation, 0, 360, 90, 0, XLAT("model orientation"), ""); }); + if(DIM == 3) { + dialog::addSelItem(XLAT("model orientation (y/z plane)"), fts(model_orientation_yz), 'L'); + dialog::add_action([] () { + dialog::editNumber(model_orientation_yz, 0, 360, 90, 0, XLAT("model orientation (y/z plane)"), ""); + }); + } } if(pmodel == mdPolynomial) { @@ -1130,6 +1139,11 @@ namespace conformal { PHASEFROM(2); shift_arg_formula(conformal::model_orientation); } + else if(argis("-mori2")) { + PHASEFROM(2); + shift_arg_formula(conformal::model_orientation); + shift_arg_formula(conformal::model_orientation_yz); + } else if(argis("-mtrans")) { PHASEFROM(2); shift_arg_formula(conformal::model_transition); diff --git a/hyper.h b/hyper.h index 3c9e8442..797a2d69 100644 --- a/hyper.h +++ b/hyper.h @@ -1396,11 +1396,11 @@ namespace conformal { extern bool use_atan; extern ld rotation; extern int do_rotate; - extern ld model_orientation; + extern ld model_orientation, model_orientation_yz; extern ld halfplane_scale; - extern ld ocos, osin; + extern ld ocos, osin, ocos_yz, osin_yz; extern ld cos_ball, sin_ball; - extern bool model_straight; + extern bool model_straight, model_straight_yz; extern ld model_transition; extern ld top_z; extern ld spiral_angle, spiral_x, spiral_y; @@ -1411,6 +1411,8 @@ namespace conformal { template void apply_orientation(A& x, A& y) { if(!model_straight) tie(x,y) = make_pair(x*ocos + y*osin, y*ocos - x*osin); } template + void apply_orientation_yz(A& x, A& y) { if(!model_straight_yz) tie(x,y) = make_pair(x*ocos_yz + y*osin_yz, y*ocos_yz - x*osin_yz); } + template void apply_ball(A& x, A& y) { tie(x,y) = make_pair(x*cos_ball + y*sin_ball, y*cos_ball - x*sin_ball); } void configure(); diff --git a/hypgraph.cpp b/hypgraph.cpp index 2dc9ceae..a07e36e7 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -186,6 +186,7 @@ void move_y_to_z(hyperpoint& H, pair coef) { template void makeband(hyperpoint H, hyperpoint& ret, const T& f) { ld zlev = find_zlev(H); + conformal::apply_orientation_yz(H[1], H[2]); conformal::apply_orientation(H[0], H[1]); auto r = move_z_to_y(H); @@ -204,6 +205,7 @@ template void makeband(hyperpoint H, hyperpoint& ret, const T& f) { ret = hpxyz(x / M_PI, y / M_PI, 0); move_y_to_z(ret, r); conformal::apply_orientation(ret[1], ret[0]); + conformal::apply_orientation_yz(ret[2], ret[1]); if(zlev != 1 && current_display->stereo_active()) apply_depth(ret, yzf / M_PI); return; @@ -311,6 +313,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { ld zlev = find_zlev(H); H = space_to_perspective(H); + conformal::apply_orientation_yz(H[1], H[2]); conformal::apply_orientation(H[0], H[1]); H[1] += 1; @@ -318,6 +321,17 @@ void applymodel(hyperpoint H, hyperpoint& ret) { H /= -rad; H[1] += .5; + if(DIM == 3) { + // a bit simpler when we do not care about 3D + ret[0] = -H[0]; + ret[1] = 1 + H[1]; + ret[2] = H[2]; + ret[3] = 1; + conformal::apply_orientation(ret[1], ret[0]); + conformal::apply_orientation_yz(ret[2], ret[1]); + break; + } + conformal::apply_orientation(H[0], H[1]); H *= conformal::halfplane_scale; @@ -411,6 +425,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { case mdJoukowsky: case mdJoukowskyInverted: { + conformal::apply_orientation_yz(H[1], H[2]); conformal::apply_orientation(H[0], H[1]); // with equal speed skiprope: conformal::apply_orientation(H[1], H[0]); @@ -471,6 +486,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { move_y_to_z(ret, yz); conformal::apply_orientation(ret[0], ret[1]); } + conformal::apply_orientation_yz(ret[2], ret[1]); break; }