forked from matalek/eth-dphpc-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometric_helpers.hh
44 lines (32 loc) · 1.01 KB
/
geometric_helpers.hh
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
// Common geometric helpers to use in different algorithms.
// Auxiliary type definitions.
#ifndef GEOMETRIC_HELPERS_HH
#define GEOMETRIC_HELPERS_HH
#include <stdio.h>
#include <vector>
#include <iostream>
typedef long long int LL;
// Macro for calculating cross product.
#define Det(a, b, c) (LL(b.x - a.x) * LL(c.y - a.y) \
- LL(b.y - a.y) * LL(c.x - a.x))
#define DetPointer(a, b, c) (LL(b->x - a->x) * LL(c->y - a->y) \
- LL(b->y - a->y) * LL(c->x - a->x))
#define abs_int(x) ((x) > 0 ? x : -x)
// Struct representing point with integer coordinates.
struct POINT {
int x, y;
POINT(int x = 0, int y = 0) : x(x), y(y) { }
bool operator ==(const POINT& a) {
return a.x == x && a.y == y;
}
void print() const {
std::cout << x << " " << y << "\n";
}
};
typedef std::vector<POINT*> POINTS;
// Function designating order with regards to coordinates of
// pointers to points set.
bool OrderXY(const POINT* a, const POINT* b) {
return a->x == b->x ? a->y < b->y : a->x < b->x;
}
#endif // GEOMETRIC_HELPERS_HH