chiark / gitweb /
Attempt at a new model top half.
authorian <ian>
Thu, 24 Sep 1998 02:29:28 +0000 (02:29 +0000)
committerian <ian>
Thu, 24 Sep 1998 02:29:28 +0000 (02:29 +0000)
main.cc
moebius.cc
moebius.hh

diff --git a/main.cc b/main.cc
index be3b53043fc73e9880e14b99c596ed70afa7c127..947faca67ccd57b4d0290e0b008c45cb15c26657 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -20,7 +20,9 @@
 
 static Parameter<int> tn("tn", "Number of sections around `strip'", 30, 1, 1, 500);
 static Parameter<int> un("un", "Number of sections across `strip'", 15, 1, 1, 500);
 
 static Parameter<int> tn("tn", "Number of sections around `strip'", 30, 1, 1, 500);
 static Parameter<int> un("un", "Number of sections across `strip'", 15, 1, 1, 500);
-static Parameter<int> orig("orig", "Use original strip (not reformulated)", 1, 0, 0, 1);
+static Parameter<int> version("version",
+                             "Version to use: 0=original strip, 1=reformulated,"
+                             " 2=reformulated again", 0, 1, 0, 2);
 static Parameter<double> theta("theta", "Angle of model rotation",
                               /*-PI/2.*/0, M_PI/8., -M_PI*2., M_PI*2.);
 static Parameter<double> eta("eta", "Angle of model elevation",
 static Parameter<double> theta("theta", "Angle of model rotation",
                               /*-PI/2.*/0, M_PI/8., -M_PI*2., M_PI*2.);
 static Parameter<double> eta("eta", "Angle of model elevation",
@@ -62,10 +64,11 @@ DualX11Output *dualx11= 0;
 void generate() {
   if (list) delete list;
   Moebius *strip;
 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;
   }
   list= new SortedCellList;
   double t0= 0.0;
index 148ce0c3da9c34772abc28d1a1a59f0d685438dd..f169ab52520866f81c40703ce1c87dab3255504d 100644 (file)
@@ -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]
 
 // 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);
 }
   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) );
   }
 }    
     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]);
+  }
+}
index e834d3b4397b148b9fb6a6d0a9de8bbf63cdd98a..f3e04390277b214c1bbe68ea3dbb2dcd2b9f4ad3 100644 (file)
@@ -43,13 +43,22 @@ public:
   Point middlepoint(double t, double u);
 };
 
   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; }
   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);
 };
 
   Point middlepoint(double t, double u);
 };