chiark / gitweb /
found in ijackson@chiark:things/moebius.old-before-cvs
[moebius.git] / moebius.hh
1 /*
2  * Moebius strip
3  */
4
5 #ifndef MOEBIUS_HH
6 #define MOEBIUS_HH
7
8 class Surface {
9 public:
10   // t and u vary from 0 to 1.0
11   virtual Point middlepoint(double t, double u) =0;
12 };
13
14 class Moebius : public Surface {
15 public:
16   virtual Point middlepoint(double t, double u) =0;
17 };
18
19 class MoebiusStrip : public Moebius {
20   // Strip is `lying' in the XY plane. The crossing is at the
21   // maximal Y value, where the edge which has X*Z positive
22   // has smaller Y at the point where X=Z=0 than the `other' edge,
23   // which has X*Z negative.  The flat part of the strip
24   // is at minimal Y value.  Here one edge has Z positive and
25   // the other Z negative.
26   // X and Y range from -1.0 to 1.0;
27   // Z ranges from -halfbreadth to +halfbreadth.
28   double halfgap;     // 1/2 the width of the strip at the crossing point
29   double halfbreadth; // 1/2 the width of the strip at the flat part
30   Point edgepoint(double t);
31 public:
32   MoebiusStrip() { halfgap= 0.15; halfbreadth= 0.15; }
33   MoebiusStrip(double b) { halfgap= halfbreadth= b/2.0; }
34   MoebiusStrip(double hg, double hb) { halfgap= hg/2.0; halfbreadth= hb/2.0; }
35     
36   Point middlepoint(double t, double u);
37 };
38
39 class MoebiusEnfoldment : public Moebius {
40   double thickness;
41   double bottomportion;
42 public:
43   MoebiusEnfoldment(double t=.35, double bp=.5) { thickness= t; bottomportion= bp; }
44     
45   Point edgepoint(double t);
46   Point middlepoint(double t, double u);
47 };
48
49 class MoebiusNewEnfoldment : public Moebius {
50 public:
51   MoebiusNewEnfoldment() { }
52     
53   Point edgepoint(double t);
54   Point middlepoint(double t, double u);
55 };
56
57 #endif