From: ian Date: Wed, 2 Jan 2008 01:33:59 +0000 (+0000) Subject: pointmap command for use by moebius2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius.git;a=commitdiff_plain;h=3341494a1fe1979641c49c65c7f09319b9eca659 pointmap command for use by moebius2 --- diff --git a/library.hh b/library.hh index bb226dd..e122a9d 100644 --- a/library.hh +++ b/library.hh @@ -57,6 +57,7 @@ public: double& operator[](int i) { return xyz[i]; } operator Onscreen() const; + Point halftransformed() const { return usertransforms(*this); } Point transformed() const { return povtransform(usertransforms(*this)); } double index() const { return transformed()[2]; } diff --git a/main.cc b/main.cc index 5a35b45..645d93a 100644 --- 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 {