3d:: change model orientation in the YZ plane

This commit is contained in:
Zeno Rogue 2019-03-20 18:32:03 +01:00
parent 745f1b302b
commit 01a2f0cc5a
4 changed files with 39 additions and 6 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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<class A>
void apply_orientation(A& x, A& y) { if(!model_straight) tie(x,y) = make_pair(x*ocos + y*osin, y*ocos - x*osin); }
template<class A>
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<class A>
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();

View File

@ -186,6 +186,7 @@ void move_y_to_z(hyperpoint& H, pair<ld, ld> coef) {
template<class T> 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<class T> 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;
}