-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtypes.h
52 lines (42 loc) · 871 Bytes
/
types.h
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
#pragma once
#include <iostream>
struct ivec2
{
int64_t x, y;
inline bool operator<(const ivec2& other) const
{
return (y != other.y) ? (y < other.y) : (x < other.x);
}
inline bool operator==(const ivec2& other) const
{
return (x == other.x) && (y == other.y);
}
inline ivec2 operator-(const ivec2& other) const
{
return ivec2{x - other.x, y - other.y};
}
inline ivec2& operator-=(const ivec2& other)
{
x -= other.x;
y -= other.y;
return *this;
}
inline int64_t operator*(const ivec2& other) const
{
return x * other.y - y * other.x;
}
inline int64_t dot(const ivec2& other) const
{
return x * other.x + y * other.y;
}
};
std::ostream& operator<<(std::ostream& out, const ivec2& vec)
{
out << vec.x << " " << vec.y;
return out;
}
std::istream& operator>>(std::istream& in, ivec2& vec)
{
in >> vec.x >> vec.y;
return in;
}