mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
120 lines
2.3 KiB
C++
120 lines
2.3 KiB
C++
#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
|