chiark / gitweb /
X window size is a parameter; scale is a parameter; whether to draw original strip...
authorian <ian>
Wed, 23 Sep 1998 00:28:30 +0000 (00:28 +0000)
committerian <ian>
Wed, 23 Sep 1998 00:28:30 +0000 (00:28 +0000)
dualx11.cc
main.cc
transforms.cc
transforms.hh
x11.cc

index dbd3e4b84a8d5a849dac18a65a40c06c38dcbdf6..5c40ba2ea2d93c683f52f4829c06a3895dfb4a1f 100644 (file)
@@ -5,6 +5,9 @@
 #include "dualx11.hh"
 #include "parameter.hh"
 
+static Parameter<int> dualx11size("dualx11size", "Dual X11 window size",
+                                 500, 100, 10, 10000);
+
 DualX11Output::DualX11Output() {
   display= XOpenDisplay(0);
   Colormap cmap= DefaultColormap(display,DefaultScreen(display));
@@ -26,7 +29,7 @@ DualX11Output::DualX11Output() {
   
   window= XCreateSimpleWindow(display,
                               DefaultRootWindow(display),
-                              0,0, 500,500, 0,0, pixelbase);
+                              0,0, dualx11size,dualx11size, 0,0, pixelbase);
 
   XGCValues gcvalues;
   int i;
@@ -69,8 +72,8 @@ void DualX11Output::drawcell(const Point* list, int n) {
     XPoint xp[n+1];
     for (int j=0; j<n; j++) {
       Onscreen here= Onscreen(list[j]);
-      xp[j].x= (int)((here.x+1.0)*250.0);
-      xp[j].y= (int)((-here.y+1.0)*250.0);
+      xp[j].x= (int)((here.x+1.0)*(dualx11size*0.5));
+      xp[j].y= (int)((-here.y+1.0)*(dualx11size*0.5));
     }
     XFillPolygon(display,window,fabric[i],xp,n,Nonconvex,CoordModeOrigin);
     xp[n]= xp[0];
diff --git a/main.cc b/main.cc
index bbe9621e138e0e50ceb24606010b3663c515a0b5..be3b53043fc73e9880e14b99c596ed70afa7c127 100644 (file)
--- a/main.cc
+++ b/main.cc
 #include "graphics.hh"
 #include "parameter.hh"
 
-Parameter<int> tn("tn", "Number of sections around `strip'", 30, 1, 1, 500);
-Parameter<int> un("un", "Number of sections across `strip'", 15, 1, 1, 500);
-Parameter<double> theta("theta", "Angle of model rotation",
-                        /*-PI/2.*/0, M_PI/8., -M_PI*2., M_PI*2.);
-Parameter<double> eta("eta", "Angle of model elevation", 0., M_PI/8., -M_PI*2., M_PI*2.);
-Parameter<double> planedistance("plane", "Distance from projection plane to origin", 
-                                4., .25, 0., 100.);
-Parameter<double> eyedistance("eye", "Distance from projection eye to origin", 
-                              1.5, .25, 0., 100.);
-Parameter<double> cutoffdistance("cutoff", "Distance from projection cutoff to origin", 
-                                 10., .25, -10., 100.);
-Parameter<double> width("width", "Width of the `strip' before transformation", 
-                        .4, .1, 0., 1.);
-Parameter<double> thickness("thick", "Thickness of the `pancake'", 1., .1, 0., 1.);
-Parameter<double> bottomportion("bp", "Proportion in the bottom half", 
-                                .7, .1, 0., 1.);
-//Parameter<double> tear("tear", "Angle factor in tear-open", 0/*1.1*/, .1, -5., 5.);
-//Parameter<double> teary("teary", "Axis y coord in tear-open", 1.3, .1, -10., 10.);
-//Parameter<double> twist("twist", "Angle per length in twist", 0/*.8*/, .25, -5., 5.);
-//Parameter<double> twisty("twisty", "Axis y coord in twist", .85, .1, -10., 10.);
-//Parameter<double> bulge("bulge", "Amount of bulge", 0/*1.*/, .25, -15., 15.);
-//Parameter<double> bulgesd("bulgesd", "S.D. of bulge", 1., .2, .000001, 20.);
-//Parameter<double> bulgey("bulgey", "Axis y coord in bulge", .85, .1, -10., 10.);
-//Parameter<double> shearx("shearx", "Amount of shear (x)", 0., .1, -15., 15.);
-//Parameter<double> sheary("sheary", "Amount of shear (y)", 0/*1.*/, .1, -15., 15.);
-//Parameter<double> shearsdx("shearsdx", "S.D. of shear (x)", .5, .1, -15., 15.);
-//Parameter<double> shearsdy("shearsdy", "S.D. of shear (y)", .5, .1, -15., 15.);
-//Parameter<double> shearey("shearey", "Centre of shear (y)", 1.3, .1, -10., 10.);
+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<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",
+                            0., M_PI/8., -M_PI*2., M_PI*2.);
+static Parameter<double> scale("scale", "Scale factor for resulting object", 
+                              1.0, 0.25, 0.001, 1000.);
+static Parameter<double> planedistance("plane",
+                                      "Distance from projection plane to origin", 
+                                      4., .25, 0., 100.);
+static Parameter<double> eyedistance("eye", "Distance from projection eye to origin", 
+                                    1.5, .25, 0., 100.);
+static Parameter<double> cutoffdistance("cutoff",
+                                       "Distance from projection cutoff to origin", 
+                                       10., .25, -10., 100.);
+static Parameter<double> width("width", "Width of the `strip' before transformation", 
+                              .4, .1, 0., 1.);
+static Parameter<double> thickness("thick", "Thickness of the `pancake'", 1., .1, 0., 1.);
+static Parameter<double> bottomportion("bp", "Proportion in the bottom half", 
+                                      .7, .1, 0., 1.);
+static Parameter<double> tear("tear", "Angle factor in tear-open",
+                             0/*1.1*/, .1, -5., 5.);
+static Parameter<double> teary("teary", "Axis y coord in tear-open", 1.3, .1, -10., 10.);
+static Parameter<double> twist("twist", "Angle per length in twist",
+                              0/*.8*/, .25, -5., 5.);
+static Parameter<double> twisty("twisty", "Axis y coord in twist", .85, .1, -10., 10.);
+static Parameter<double> bulge("bulge", "Amount of bulge", 0/*1.*/, .25, -15., 15.);
+static Parameter<double> bulgesd("bulgesd", "S.D. of bulge", 1., .2, .000001, 20.);
+static Parameter<double> bulgey("bulgey", "Axis y coord in bulge", .85, .1, -10., 10.);
+static Parameter<double> shearx("shearx", "Amount of shear (x)", 0., .1, -15., 15.);
+static Parameter<double> sheary("sheary", "Amount of shear (y)", 0/*1.*/, .1, -15., 15.);
+static Parameter<double> shearsdx("shearsdx", "S.D. of shear (x)", .5, .1, -15., 15.);
+static Parameter<double> shearsdy("shearsdy", "S.D. of shear (y)", .5, .1, -15., 15.);
+static Parameter<double> shearey("shearey", "Centre of shear (y)", 1.3, .1, -10., 10.);
 
 SortedCellList *list=0;
 X11Output *x11= 0;
@@ -53,8 +61,12 @@ DualX11Output *dualx11= 0;
 
 void generate() {
   if (list) delete list;
-  // MoebiusStrip strip(width);
-  MoebiusEnfoldment strip(thickness,bottomportion);
+  Moebius *strip;
+  if (orig) {
+    strip= new MoebiusStrip(width);
+  } else {
+    strip= new MoebiusEnfoldment(thickness,bottomportion);
+  }
   list= new SortedCellList;
   double t0= 0.0;
   for (int ti=0; ti<tn; ti++) {
@@ -64,17 +76,18 @@ void generate() {
       double u1= (double)(ui+1)/un;
       Cell *cell= new Cell;
 //u0=u1=tear;
-      cell->p[0]= strip.middlepoint(t0,u0);
+      cell->p[0]= strip->middlepoint(t0,u0);
 //fprintf(stderr,"t %7.4f u %7.4f  %7.4f,%7.4f,%7.4f\n",
 //        t0,u0, cell->p[0][0], cell->p[0][1], cell->p[0][2]);
-      cell->p[1]= strip.middlepoint(t0,u1);
-      cell->p[2]= strip.middlepoint(t1,u1);
-      cell->p[3]= strip.middlepoint(t1,u0);
+      cell->p[1]= strip->middlepoint(t0,u1);
+      cell->p[2]= strip->middlepoint(t1,u1);
+      cell->p[3]= strip->middlepoint(t1,u0);
       list->insert(cell);
       u0= u1;
     }
     t0= t1;
   }
+  delete strip;
 }
 
 int main(int argc, char **argv) {
@@ -83,13 +96,14 @@ int main(int argc, char **argv) {
   for (;;) {
     Point::setobserver(theta,eta,planedistance,eyedistance,cutoffdistance);
     Point::cleartransform();
-//    if (tear != 0.0) Point::appendtransform(new TearOpenTransform(tear,teary));
-//    if (twist != 0.0) Point::appendtransform(new TwistTransform(twist,twisty));
-//    if (bulge != 0.0) Point::appendtransform(new BulgeTransform(bulge,bulgesd,bulgey));
-//    if (shearx != 0.0 || sheary != 0.0)
-//      Point::appendtransform(new ShearTransform(Point(0.0,shearey,0.0),
-//                                                Point(shearx,sheary,0.0),
-//                                                Point(shearsdx,shearsdy,1e20)));
+    if (tear != 0.0) Point::appendtransform(new TearOpenTransform(tear,teary));
+    if (twist != 0.0) Point::appendtransform(new TwistTransform(twist,twisty));
+    if (bulge != 0.0) Point::appendtransform(new BulgeTransform(bulge,bulgesd,bulgey));
+    if (shearx != 0.0 || sheary != 0.0)
+      Point::appendtransform(new ShearTransform(Point(0.0,shearey,0.0),
+                                                Point(shearx,sheary,0.0),
+                                                Point(shearsdx,shearsdy,1e20)));
+    Point::appendtransform(new ScaleTransform(scale));
     generate();
     if (x11) list->display(*x11);
     if (dualx11) list->display(*dualx11);
@@ -149,4 +163,3 @@ int main(int argc, char **argv) {
     }
   }
 }
-
index d5b6cd6bb230a8782057cbf0fae84110b5446578..abd3fce3bb8bbf338021df6962f8919a24f7c1bf 100644 (file)
@@ -68,6 +68,10 @@ Point TwistTransform::operator()(Point in) {
   return Point(nx,ny,in[2]);
 }
 
+Point ScaleTransform::operator()(Point in) {
+  return in*scale;
+}
+
 Point MagicTransform::operator()(Point in) {
   double nz= in[2]*zfactor;
   double r= sqrt(in[0]*in[0] + in[1]*in[1]);
index e398d279b96d96a3dd89d96d3688cbc9146f8916..bb7c3ce0bec01ab8396bc2e46c58a05e23c089b5 100644 (file)
@@ -78,6 +78,13 @@ public:
   Point operator()(Point in);
 };
 
+class ScaleTransform : public Transform {
+  double scale;
+public:
+  ScaleTransform(double s) { scale= s; }
+  Point operator()(Point in);
+};
+
 class MagicTransform : public Transform {
   double xkonstant, xfactor, yoffset, yfactor, zfactor;
 public:
diff --git a/x11.cc b/x11.cc
index b724594e676253fef6a5bb80082704495b67838a..b88a5e9da69279a3a59573afb18cdb81ba311972 100644 (file)
--- a/x11.cc
+++ b/x11.cc
@@ -4,13 +4,16 @@
 
 
 #include "x11.hh"
+#include "parameter.hh"
+
+static Parameter<int> x11size("x11size", "X11 window size", 500, 100, 10, 10000);
 
 X11Output::X11Output() {
   XGCValues gcvalues;
   display= XOpenDisplay(0);
   window= XCreateSimpleWindow(display,
                               DefaultRootWindow(display),
-                              0,0, 500,500, 0,0,0);
+                              0,0, x11size,x11size, 0,0,0);
   gcvalues.background= 0;
   fabric= XCreateGC(display,window,GCBackground,&gcvalues);
   gcvalues.foreground= 1;
@@ -37,8 +40,8 @@ void X11Output::drawcell(const Point* list, int n) {
   XPoint xp[n+1];
   for (int i=0; i<n; i++) {
     Onscreen here= Onscreen(list[i]);
-    xp[i].x= (int)((here.x+1.0)*250.0);
-    xp[i].y= (int)((-here.y+1.0)*250.0);
+    xp[i].x= (int)((here.x+1.0)*(x11size*0.5));
+    xp[i].y= (int)((-here.y+1.0)*(x11size*0.5));
   }
   XFillPolygon(display,window,fabric,xp,n,Nonconvex,CoordModeOrigin);
   xp[n]= xp[0];