summaryrefslogtreecommitdiff
path: root/graphics/metaplot/examples/cpoint.h
blob: dc5a45fecccf5f1d414a8ed43a262a5718081860 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* MetaContour, version 0.1 -------------------------------------- */
/* Copyright(C) 2004, Brooks Moses                                 */
/*                                                                 */
/* This version of MetaContour is made available under the Gnu     */
/* Public License; see metacontour_main.cc for details.            */
/*                                                                 */
/* This is a very pre-release version of MetaContour, distributed  */
/* primarily as an example of a use of MetaPlot.  It can be        */
/* compiled with gcc using the line:                               */
/*                                                                 */
/*   g++ metacontour.cc cpoint.cc metacontour_main.cc              */
/*                                                                 */
/*-----------------------------------------------------------------*/

/* Class for 2D points with one data value each */  

#include<string>
#include<valarray>
using namespace std;
  
struct cpoint {
  double x;
  double y;
  double z;

  cpoint();
  cpoint(double, double, double);
  
  cpoint interpolateto(cpoint, double);
  cpoint partwayto(cpoint, double);
  static double saddlepoint(cpoint, cpoint, cpoint, cpoint);

  string metapoint();
};


class cparray {
  valarray<cpoint>* a;
  int i;
  int j;
public:
  cparray(int x, int y);        // note: no default constructor
  cparray(const cparray&);
  cparray& operator=(const cparray&);
  ~cparray();

  int size() const { return i*j; }
  int i_dim() const { return i; }
  int j_dim() const { return j; }

  cpoint& operator()(int x, int y);         // Fortran-style subscripts
  cpoint operator()(int x, int y) const;

  valarray<cpoint>& array() { return *a; }
};