Debian Codegraph @

texmf-dist/doc/latex/metaplot/examples/cpoint.h

raw
1 /* MetaContour, version 0.1 -------------------------------------- */
2 /* Copyright(C) 2004, Brooks Moses */
3 /* */
4 /* This version of MetaContour is made available under the Gnu */
5 /* Public License; see metacontour_main.cc for details. */
6 /* */
7 /* This is a very pre-release version of MetaContour, distributed */
8 /* primarily as an example of a use of MetaPlot. It can be */
9 /* compiled with gcc using the line: */
10 /* */
11 /* g++ metacontour.cc cpoint.cc metacontour_main.cc */
12 /* */
13 /*-----------------------------------------------------------------*/
14
15 /* Class for 2D points with one data value each */
16
17 #include<string>
18 #include<valarray>
19 using namespace std;
20
21 struct cpoint {
22 double x;
23 double y;
24 double z;
25
26 cpoint();
27 cpoint(double, double, double);
28
29 cpoint interpolateto(cpoint, double);
30 cpoint partwayto(cpoint, double);
31 static double saddlepoint(cpoint, cpoint, cpoint, cpoint);
32
33 string metapoint();
34 };
35
36
37 class cparray {
38 valarray<cpoint>* a;
39 int i;
40 int j;
41 public:
42 cparray(int x, int y); // note: no default constructor
43 cparray(const cparray&);
44 cparray& operator=(const cparray&);
45 ~cparray();
46
47 int size() const { return i*j; }
48 int i_dim() const { return i; }
49 int j_dim() const { return j; }
50
51 cpoint& operator()(int x, int y); // Fortran-style subscripts
52 cpoint operator()(int x, int y) const;
53
54 valarray<cpoint>& array() { return *a; }
55 };
56
57