~ubuntu-branches/ubuntu/saucy/python-scipy/saucy

« back to all changes in this revision

Viewing changes to scipy/sandbox/delaunay/delaunay_utils.h

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#ifndef _DELAUNAY_UTILS_H
 
3
#define _DELAUNAY_UTILS_H
 
4
 
 
5
#include <vector>
 
6
#include <queue>
 
7
#include <functional>
 
8
 
 
9
using namespace std;
 
10
 
 
11
#define ONRIGHT(x0, y0, x1, y1, x, y) ((y0-y)*(x1-x) > (x0-x)*(y1-y))
 
12
#define EDGE0(node) ((node + 1) % 3)
 
13
#define EDGE1(node) ((node + 2) % 3)
 
14
#define INDEX2(arr,ix,jx) (arr[2*ix+jx])
 
15
#define INDEX3(arr,ix,jx) (arr[3*ix+jx])
 
16
#define INDEXN(arr,N,ix,jx) (arr[N*ix+jx])
 
17
#define SQ(a) ((a)*(a))
 
18
 
 
19
#define TOLERANCE_EPS (4e-13)
 
20
#define PERTURB_EPS (1e-3)
 
21
#define GINORMOUS (1e100)
 
22
 
 
23
extern int walking_triangles(int start, double targetx, double targety, 
 
24
    double *x, double *y, int *nodes, int *neighbors);
 
25
extern void getminmax(double *arr, int n, double& minimum, double& maximum);
 
26
extern bool circumcenter(double x0, double y0,
 
27
                         double x1, double y1,
 
28
                         double x2, double y2,
 
29
                         double& centerx, double& centery);
 
30
extern double signed_area(double x0, double y0,
 
31
                          double x1, double y1,
 
32
                          double x2, double y2);
 
33
 
 
34
class SeededPoint {
 
35
public:
 
36
    SeededPoint() {};
 
37
    SeededPoint(double x0c, double y0c, double xc, double yc) {
 
38
        this->x0 = x0c;
 
39
        this->y0 = y0c;
 
40
        this->x = xc;
 
41
        this->y = yc;
 
42
    };
 
43
    ~SeededPoint() {};
 
44
 
 
45
    double x0, y0;
 
46
    double x, y;
 
47
 
 
48
    bool operator<(const SeededPoint& p2) const {
 
49
        double test = (this->y0-p2.y)*(this->x-p2.x) - (this->x0-p2.x)*(this->y-p2.y);
 
50
        if (test == 0) {
 
51
            double length1 = SQ(this->x-this->x0) + SQ(this->y-this->y0);
 
52
            double length2 = SQ(p2.x-this->x0) + SQ(p2.y-this->y0);
 
53
 
 
54
            return (length2 > length1);
 
55
        } else return (test < 0);
 
56
    }
 
57
 
 
58
};
 
59
 
 
60
class ConvexPolygon {
 
61
public:
 
62
    ConvexPolygon();
 
63
    ~ConvexPolygon();
 
64
 
 
65
    void seed(double x0c, double y0c);
 
66
    void push(double x, double y);
 
67
 
 
68
    double area();
 
69
 
 
70
// private:  // I don't care much for data-hiding
 
71
    double x0, y0;
 
72
    vector<SeededPoint> points;
 
73
    bool seeded;
 
74
};
 
75
 
 
76
 
 
77
#endif // _DELAUNAY_UTILS_H