From fe01d70c022d8106f146444bbbd7c00cf49d6ca2 Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 24 Sep 1998 02:29:28 +0000 Subject: [PATCH] Attempt at a new model top half. --- main.cc | 13 ++++++++----- moebius.cc | 36 +++++++++++++++++++++++++++++++++++- moebius.hh | 15 ++++++++++++--- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/main.cc b/main.cc index be3b530..947faca 100644 --- a/main.cc +++ b/main.cc @@ -20,7 +20,9 @@ static Parameter tn("tn", "Number of sections around `strip'", 30, 1, 1, 500); static Parameter un("un", "Number of sections across `strip'", 15, 1, 1, 500); -static Parameter orig("orig", "Use original strip (not reformulated)", 1, 0, 0, 1); +static Parameter version("version", + "Version to use: 0=original strip, 1=reformulated," + " 2=reformulated again", 0, 1, 0, 2); static Parameter theta("theta", "Angle of model rotation", /*-PI/2.*/0, M_PI/8., -M_PI*2., M_PI*2.); static Parameter eta("eta", "Angle of model elevation", @@ -62,10 +64,11 @@ DualX11Output *dualx11= 0; void generate() { if (list) delete list; Moebius *strip; - if (orig) { - strip= new MoebiusStrip(width); - } else { - strip= new MoebiusEnfoldment(thickness,bottomportion); + switch (version) { + case 0: strip= new MoebiusStrip(width); break; + case 1: strip= new MoebiusEnfoldment(thickness,bottomportion); break; + case 2: strip= new MoebiusEnfoldmentNew(); break; + default: abort(); } list= new SortedCellList; double t0= 0.0; diff --git a/moebius.cc b/moebius.cc index 148ce0c..f169ab5 100644 --- a/moebius.cc +++ b/moebius.cc @@ -46,7 +46,7 @@ void Bezier::debug() { // The first end is oriented towards [0,cos(theta),sin(theta)] // The second end is oriented towards [0,-1,0] -Point MoebiusEnfoldment::edgepoint(double t) { +Point MoebiusEnfoldmentAny::edgepoint(double t) { double theta= t*2.0*M_PI; return Point(sin(theta),cos(theta),0); } @@ -74,3 +74,37 @@ Point MoebiusEnfoldment::middlepoint(double t, double u) { return Point( bx(t), by(t), thickness * bz(t) ); } } + +Point MoebiusEnfoldmentNew::middlepoint(double t, double u) { + if (u <= 0.5) { + if (t <= 0.5) { + double sin_pi_t= sin(M_PI*t); + double cos_pi_t= cos(M_PI*t); + double sin_2pi_t= sin(2.0*M_PI*t); + double cos_2pi_t= cos(2.0*M_PI*t); + + double prop_circ= 0.5+0.5*cos(2.0*M_PI*u); + // double prop_circ= 1.0-2.0*u; + + Point p_edge(-sin_pi_t,cos_pi_t,0); + + double alpha_circ= (2.0*M_PI)*(2.0*t)*(2.0*u); + Point v_edge1(cos_2pi_t*sin_pi_t,-cos_2pi_t*cos_pi_t,sin_2pi_t); + Point v_edge2(sin_2pi_t*cos_pi_t,-sin_2pi_t*sin_pi_t,-cos_2pi_t); + Point p_circ_cent= p_edge + v_edge2*(2.0*t); + Point p_circ_pt= p_circ_cent + (v_edge1*sin(alpha_circ) + v_edge2*-cos(alpha_circ))*(2.0*t); + p_circ_pt[1]= p_edge[1]; + + Point v_line(-cos_pi_t,0,sin_pi_t); + Point p_line_start(0,1.0-2.0*t,0); + Point p_line_pt= p_line_start + v_line*(1.0-2.0*u)*(M_PI*t); + + return p_circ_pt*prop_circ + p_line_pt*(1.0-prop_circ); + } else { + return middlepoint(0.5,u) + Point(0,0.5-t,0); + } + } else { + Point p_mirror= middlepoint(t,1.0-u); + return Point(-p_mirror[0], p_mirror[1], -p_mirror[2]); + } +} diff --git a/moebius.hh b/moebius.hh index e834d3b..f3e0439 100644 --- a/moebius.hh +++ b/moebius.hh @@ -43,13 +43,22 @@ public: Point middlepoint(double t, double u); }; -class MoebiusEnfoldment : public Moebius { +class MoebiusEnfoldmentAny : public Moebius { +public: + Point edgepoint(double t); +}; + +class MoebiusEnfoldment : public MoebiusEnfoldmentAny { double thickness; double bottomportion; public: MoebiusEnfoldment(double t=.35, double bp=.5) { thickness= t; bottomportion= bp; } - - Point edgepoint(double t); + Point middlepoint(double t, double u); +}; + +class MoebiusEnfoldmentNew : public MoebiusEnfoldmentAny { +public: + MoebiusEnfoldmentNew() { } Point middlepoint(double t, double u); }; -- 2.30.2