-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_CLtypes.hpp
62 lines (58 loc) · 2.14 KB
/
02_CLtypes.hpp
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
58
59
60
61
62
typedef uint8_t uchar;
#define __pair(dt, st)\
st x;\
st y;\
dt () : x(0), y(0) {}\
dt (const st in) : x(in), y(in) {}\
dt (const st xIn, const st yIn) : x(xIn), y(yIn) {}\
dt operator + (const dt b) {return dt(x + b.x, y + b.y);}\
dt operator - (const dt b) {return dt(x - b.x, y - b.y);}\
dt operator * (const dt b) {return dt(x * b.x, y * b.y);}\
dt operator / (const dt b) {return dt(x / b.x, y / b.y);}\
bool operator == (const dt b) {return x == b.x && y == b.y;}\
bool operator != (const dt b) {return x != b.x || y != b.y;}\
void operator += (const dt b) {x += b.x; y += b.y;}\
void operator -= (const dt b) {x -= b.x; y -= b.y;}\
void operator *= (const dt b) {x *= b.x; y *= b.y;}\
void operator /= (const dt b) {x /= b.x; y /= b.y;}\
dt operator + (const st b) {return dt(x + b, y + b);}\
dt operator - (const st b) {return dt(x - b, y - b);}\
dt operator * (const st b) {return dt(x * b, y * b);}\
dt operator / (const st b) {return dt(x / b, y / b);}\
bool operator == (const st b) {return x == b && y == b;}\
bool operator != (const st b) {return x != b || y != b;}\
void operator += (const st b) {x += b; y += b;}\
void operator -= (const st b) {x -= b; y -= b;}\
void operator *= (const st b) {x *= b; y *= b;}\
void operator /= (const st b) {x /= b; y /= b;}\
void operator = (const st b) {x = b; y = b;}\
bool operator ! () {return !x && !y;}\
st pro() {return x*y;}\
bool upLeftOf (dt b) {return x < b.x && y < b.y;}\
bool upRightOf(dt b) {return x > b.x && y < b.y;}\
bool dnLeftOf (dt b) {return x < b.x && y > b.y;}\
bool dnRightOf(dt b) {return x > b.x && y > b.y;}\
st sel(uint8_t axis) {\
switch(axis) {\
case 0: return x;\
case 1: return y;\
default: return 0;\
}\
}\
st *pSel(uint8_t axis) {\
switch(axis) {\
case 0: return &x;\
case 1: return &y;\
default: return 0;\
}\
}\
struct int2{
__pair(int2, int);
//int2(float2 f) : x(f.x), y(f.y) {}
int2 operator % (const int2 b) {return int2(x % b.x, y % b.y);}
int2 operator % (const int b) {return int2(x % b , y % b );}
};
struct float2{
__pair(float2, float);
float2(int2 i) : x(i.x), y(i.y) {}
};