15 IVector_2(
int X,
int Y) : x(X), y(Y) { }
16 IVector_2(
const IVector_2 &v) : x(v.x), y(v.y) { }
17 IVector_2& operator=(
const IVector_2 &v) { x = v.x; y = v.y;
return *
this; }
18 bool operator==(
const IVector_2 &v)
const {
return x == v.x && y == v.y; }
19 bool operator!=(
const IVector_2 &v)
const {
return x != v.x || y != v.y; }
20 IVector_2 operator+(
const IVector_2 &v)
const {
return IVector_2(x + v.x, y + v.y); }
21 IVector_2 operator-(
const IVector_2 &v)
const {
return IVector_2(x - v.x, y - v.y); }
22 IVector_2 operator*(
int s)
const {
return IVector_2(x * s, y * s); }
23 IVector_2 operator/(
int s)
const {
return IVector_2((x + s - 1) / s, (y + s - 1) / s); }
24 IVector_2& operator+=(
const IVector_2 &v) { x += v.x; y += v.y;
return *
this; }
25 IVector_2& operator-=(
const IVector_2 &v) { x -= v.x; y -= v.y;
return *
this; }
26 IVector_2& operator*=(
int s) { *
this = *
this * s;
return *
this; }
27 IVector_2& operator/=(
int s) { *
this = *
this / s;
return *
this; }
28 IVector_2 abs()
const {
return IVector_2(std::abs(x), std::abs(y)); }
29 int32_t dot(
const IVector_2 &v)
const {
return x * v.x + y * v.y; }
30 int32_t norm1()
const {
return std::abs(x) + std::abs(y); }
31 int32_t hprod()
const {
return x * y; }
32 IVector_2 max_cw(
const IVector_2 &v)
const {
return IVector_2(std::max(x, v.x), std::max(y, v.y)); }
33 IVector_2 min_cw(
const IVector_2 &v)
const {
return IVector_2(std::min(x, v.x), std::min(y, v.y)); }
42 IPoint_2(
int X,
int Y) : x(X), y(Y) { }
43 IPoint_2(
const IVector_2 &v) : x(v.x), y(v.y) { }
44 IPoint_2(
const int *v) : x(v[0]), y(v[1]) { }
45 IPoint_2(
const uint *v) : x(v[0]), y(v[1]) { }
46 IPoint_2& operator=(
const IPoint_2 &P) { x = P.x; y = P.y;
return *
this; }
47 bool operator==(
const IPoint_2 &P)
const {
return x == P.x && y == P.y; }
48 bool operator!=(
const IPoint_2 &P)
const {
return x != P.x || y != P.y; }
49 bool isPositive()
const {
return x >= 0 && y >= 0; }
50 IPoint_2 operator+(
const IVector_2 &v)
const {
return IPoint_2(x + v.x, y + v.y); }
51 IPoint_2 operator-(
const IVector_2 &v)
const {
return IPoint_2(x - v.x, y - v.y); }
52 IPoint_2& operator+=(
const IVector_2 &v) { x += v.x; y += v.y;
return *
this; }
53 IPoint_2& operator-=(
const IVector_2 &v) { x -= v.x; y -= v.y;
return *
this; }