2
#ifndef _DELAUNAY_UTILS_H
3
#define _DELAUNAY_UTILS_H
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))
19
#define TOLERANCE_EPS (4e-13)
20
#define PERTURB_EPS (1e-3)
21
#define GINORMOUS (1e100)
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,
29
double& centerx, double& centery);
30
extern double signed_area(double x0, double y0,
32
double x2, double y2);
37
SeededPoint(double x0c, double y0c, double xc, double yc) {
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);
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);
54
return (length2 > length1);
55
} else return (test < 0);
65
void seed(double x0c, double y0c);
66
void push(double x, double y);
70
// private: // I don't care much for data-hiding
72
vector<SeededPoint> points;
77
#endif // _DELAUNAY_UTILS_H