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 Edge {
15 public:
16   // t varies from 0 to 1.0
17   virtual Point edgepoint(double t) =0;
18 };
19
20 class Moebius : public Surface, Edge {
21 public:
22   virtual Point edgepoint(double t) =0;
23   virtual Point middlepoint(double t, double u) =0;
24 };
25
26 class MoebiusStrip : public Moebius {
27   // Strip is `lying' in the XY plane. The crossing is at the
28   // maximal Y value, where the edge which has X*Z positive
29   // has smaller Y at the point where X=Z=0 than the `other' edge,
30   // which has X*Z negative.  The flat part of the strip
31   // is at minimal Y value.  Here one edge has Z positive and
32   // the other Z negative.
33   // X and Y range from -1.0 to 1.0;
34   // Z ranges from -halfbreadth to +halfbreadth.
35   double halfgap;     // 1/2 the width of the strip at the crossing point
36   double halfbreadth; // 1/2 the width of the strip at the flat part
37 public:
38   MoebiusStrip() { halfgap= 0.15; halfbreadth= 0.15; }
39   MoebiusStrip(double b) { halfgap= halfbreadth= b/2.0; }
40   MoebiusStrip(double hg, double hb) { halfgap= hg/2.0; halfbreadth= hb/2.0; }
41     
42   Point edgepoint(double t);
43   Point middlepoint(double t, double u);
44 };
45
46 class MoebiusEnfoldment : public Moebius {
47   double thickness;
48   double bottomportion;
49 public:
50   MoebiusEnfoldment(double t=.35, double bp=.5) { thickness= t; bottomportion= bp; }
51     
52   Point edgepoint(double t);
53   Point middlepoint(double t, double u);
54 };
55
56 #endif