X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius.git;a=blobdiff_plain;f=main.cc;h=fbacbfb985846c958f9c517beab2c3b762d099b4;hp=700719426255463c5ad67ebfada24e17ca8fec03;hb=6e671e517740cb5d1b08973cee0ec71cc104a3f6;hpb=1ddaa7bdf04344661fa4d9339ee85f49cbbf3ad9 diff --git a/main.cc b/main.cc index 7007194..fbacbfb 100644 --- a/main.cc +++ b/main.cc @@ -18,34 +18,44 @@ #include "graphics.hh" #include "parameter.hh" -Parameter tn("tn", "Number of sections around `strip'", 30, 1, 1, 500); -Parameter un("un", "Number of sections across `strip'", 15, 1, 1, 500); -Parameter theta("theta", "Angle of model rotation", - /*-PI/2.*/0, PI/8., -PI*2., PI*2.); -Parameter eta("eta", "Angle of model elevation", 0., PI/8., -PI*2., PI*2.); -Parameter planedistance("plane", "Distance from projection plane to origin", - 4., .25, 0., 100.); -Parameter eyedistance("eye", "Distance from projection eye to origin", - 1.5, .25, 0., 100.); -Parameter cutoffdistance("cutoff", "Distance from projection cutoff to origin", - 10., .25, -10., 100.); -Parameter width("width", "Width of the `strip' before transformation", - .4, .1, 0., 1.); -Parameter thickness("thick", "Thickness of the `pancake'", 1., .1, 0., 1.); -Parameter bottomportion("bp", "Proportion in the bottom half", - .7, .1, 0., 1.); -//Parameter tear("tear", "Angle factor in tear-open", 0/*1.1*/, .1, -5., 5.); -//Parameter teary("teary", "Axis y coord in tear-open", 1.3, .1, -10., 10.); -//Parameter twist("twist", "Angle per length in twist", 0/*.8*/, .25, -5., 5.); -//Parameter twisty("twisty", "Axis y coord in twist", .85, .1, -10., 10.); -//Parameter bulge("bulge", "Amount of bulge", 0/*1.*/, .25, -15., 15.); -//Parameter bulgesd("bulgesd", "S.D. of bulge", 1., .2, .000001, 20.); -//Parameter bulgey("bulgey", "Axis y coord in bulge", .85, .1, -10., 10.); -//Parameter shearx("shearx", "Amount of shear (x)", 0., .1, -15., 15.); -//Parameter sheary("sheary", "Amount of shear (y)", 0/*1.*/, .1, -15., 15.); -//Parameter shearsdx("shearsdx", "S.D. of shear (x)", .5, .1, -15., 15.); -//Parameter shearsdy("shearsdy", "S.D. of shear (y)", .5, .1, -15., 15.); -//Parameter shearey("shearey", "Centre of shear (y)", 1.3, .1, -10., 10.); +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 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", + 0., M_PI/8., -M_PI*2., M_PI*2.); +static Parameter scale("scale", "Scale factor for resulting object", + 1.0, 0.25, 0.001, 1000.); +static Parameter planedistance("plane", + "Distance from projection plane to origin", + 4., .25, 0., 100.); +static Parameter eyedistance("eye", "Distance from projection eye to origin", + 1.5, .25, 0., 100.); +static Parameter cutoffdistance("cutoff", + "Distance from projection cutoff to origin", + 10., .25, -10., 100.); +static Parameter width("width", "Width of the `strip' before transformation", + .4, .1, 0., 1.); +static Parameter thickness("thick", "Thickness of the `pancake'", 1., .1, 0., 1.); +static Parameter bottomportion("bp", "Proportion in the bottom half", + .7, .1, 0., 1.); +static Parameter tear("tear", "Angle factor in tear-open", + 0/*1.1*/, .1, -5., 5.); +static Parameter teary("teary", "Axis y coord in tear-open", 1.3, .1, -10., 10.); +static Parameter twist("twist", "Angle per length in twist", + 0/*.8*/, .25, -5., 5.); +static Parameter twisty("twisty", "Axis y coord in twist", .85, .1, -10., 10.); +static Parameter bulge("bulge", "Amount of bulge", 0/*1.*/, .25, -15., 15.); +static Parameter bulgesd("bulgesd", "S.D. of bulge", 1., .2, .000001, 20.); +static Parameter bulgey("bulgey", "Axis y coord in bulge", .85, .1, -10., 10.); +static Parameter shearx("shearx", "Amount of shear (x)", 0., .1, -15., 15.); +static Parameter sheary("sheary", "Amount of shear (y)", 0/*1.*/, .1, -15., 15.); +static Parameter shearsdx("shearsdx", "S.D. of shear (x)", .5, .1, -15., 15.); +static Parameter shearsdy("shearsdy", "S.D. of shear (y)", .5, .1, -15., 15.); +static Parameter shearey("shearey", "Centre of shear (y)", 1.3, .1, -10., 10.); SortedCellList *list=0; X11Output *x11= 0; @@ -53,8 +63,13 @@ DualX11Output *dualx11= 0; void generate() { if (list) delete list; - // MoebiusStrip strip(width); - MoebiusEnfoldment strip(thickness,bottomportion); + Moebius *strip; + 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; for (int ti=0; tip[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,21 +99,21 @@ 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); for (;;) { - cin.get(buf,100,'\n'); - char c; - if (!cin.get(c) || c!='\n') { - cerr << "error reading command input, giving up\n"; + cin.getline(buf,sizeof(buf),'\n'); + if (!cin.good()) { + cerr << "error reading command input, giving up\n"; exit(1); } char *equals= strchr(buf,'='); @@ -149,4 +165,3 @@ int main(int argc, char **argv) { } } } -