chiark / gitweb /
pointmap command for use by moebius2
[moebius.git] / main.cc
diff --git a/main.cc b/main.cc
index 5a35b453737d4543413ca6793a331c0a8ff4f00b..645d93a568db6c4df3907f622413631f9e62ca1b 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -101,9 +101,11 @@ SortedCellList *list=0;
 X11Output *x11= 0;
 DualX11Output *dualx11= 0;
 
+static Moebius *strip= 0;
+
 void generate() {
   if (list) delete list;
-  Moebius *strip;
+  if (strip) { delete strip; strip= 0; }
   switch (version) {
   case 0: strip= new MoebiusStrip(width);                           break;
   case 1: strip= new MoebiusEnfoldment(thickness,bottomportion);    break;
@@ -130,11 +132,12 @@ void generate() {
     }
     t0= t1;
   }
-  delete strip;
 }
 
 int main(int argc, char **argv) {
+  static const char pointmap_cmd[]= "pointmap ";
   char buf[100];
+  double pointmap_t, pointmap_u;
 
   for (;;) {
     Point::setobserver(theta,eta,planedistance,eyedistance,cutoffdistance);
@@ -200,6 +203,15 @@ int main(int argc, char **argv) {
         AnyParameter::help();
       } else if (!strcmp(buf,"help")) {
         AnyParameter::list();
+      } else if (!strncmp(buf,pointmap_cmd,sizeof(pointmap_cmd)-1)) {
+       if (sscanf(buf+sizeof(pointmap_cmd)-1, "%lf %lf",
+                  &pointmap_t, &pointmap_u) != 2) {
+         cerr << "failed to parse pointmap args\n";
+         continue;
+       }
+       Point p= strip->middlepoint(pointmap_t,pointmap_u);
+       cout << "\n";
+       for (int i=0; i<3; i++) cout << p.halftransformed()[i] << "\n";
       } else if (!*buf) {
         break;
       } else {