summaryrefslogtreecommitdiffstats
path: root/include/mapbox/geometry/point_arithmetic.hpp
blob: 3940e5b52c2945b4bb037b636923ca360c849c2f (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once

namespace mapbox {
namespace geometry {

template <typename T>
constexpr point<T> operator+(point<T> const& lhs, point<T> const& rhs)
{
    return point<T>(lhs.x + rhs.x, lhs.y + rhs.y);
}

template <typename T>
constexpr point<T> operator+(point<T> const& lhs, T const& rhs)
{
    return point<T>(lhs.x + rhs, lhs.y + rhs);
}

template <typename T>
constexpr point<T> operator-(point<T> const& lhs, point<T> const& rhs)
{
    return point<T>(lhs.x - rhs.x, lhs.y - rhs.y);
}

template <typename T>
constexpr point<T> operator-(point<T> const& lhs, T const& rhs)
{
    return point<T>(lhs.x - rhs, lhs.y - rhs);
}

template <typename T>
constexpr point<T> operator*(point<T> const& lhs, point<T> const& rhs)
{
    return point<T>(lhs.x * rhs.x, lhs.y * rhs.y);
}

template <typename T>
constexpr point<T> operator*(point<T> const& lhs, T const& rhs)
{
    return point<T>(lhs.x * rhs, lhs.y * rhs);
}

template <typename T>
constexpr point<T> operator/(point<T> const& lhs, point<T> const& rhs)
{
    return point<T>(lhs.x / rhs.x, lhs.y / rhs.y);
}

template <typename T>
constexpr point<T> operator/(point<T> const& lhs, T const& rhs)
{
    return point<T>(lhs.x / rhs, lhs.y / rhs);
}

template <typename T>
constexpr point<T>& operator+=(point<T>& lhs, point<T> const& rhs)
{
    lhs.x += rhs.x;
    lhs.y += rhs.y;
    return lhs;
}

template <typename T>
constexpr point<T>& operator+=(point<T>& lhs, T const& rhs)
{
    lhs.x += rhs;
    lhs.y += rhs;
    return lhs;
}

template <typename T>
constexpr point<T>& operator-=(point<T>& lhs, point<T> const& rhs)
{
    lhs.x -= rhs.x;
    lhs.y -= rhs.y;
    return lhs;
}

template <typename T>
constexpr point<T>& operator-=(point<T>& lhs, T const& rhs)
{
    lhs.x -= rhs;
    lhs.y -= rhs;
    return lhs;
}

template <typename T>
constexpr point<T>& operator*=(point<T>& lhs, point<T> const& rhs)
{
    lhs.x *= rhs.x;
    lhs.y *= rhs.y;
    return lhs;
}

template <typename T>
constexpr point<T>& operator*=(point<T>& lhs, T const& rhs)
{
    lhs.x *= rhs;
    lhs.y *= rhs;
    return lhs;
}

template <typename T>
constexpr point<T>& operator/=(point<T>& lhs, point<T> const& rhs)
{
    lhs.x /= rhs.x;
    lhs.y /= rhs.y;
    return lhs;
}

template <typename T>
constexpr point<T>& operator/=(point<T>& lhs, T const& rhs)
{
    lhs.x /= rhs;
    lhs.y /= rhs;
    return lhs;
}

} // namespace geometry
} // namespace mapbox