From 0ed2885ececf079f16b42fec60a4dc86285b5101 Mon Sep 17 00:00:00 2001 From: zheng_wenlong <wenlong_zheng@nexty-ele.com> Date: Wed, 7 Nov 2018 11:06:42 +0900 Subject: add tbtnavi source --- include/mapbox/geometry/point_arithmetic.hpp | 119 +++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 include/mapbox/geometry/point_arithmetic.hpp (limited to 'include/mapbox/geometry/point_arithmetic.hpp') diff --git a/include/mapbox/geometry/point_arithmetic.hpp b/include/mapbox/geometry/point_arithmetic.hpp new file mode 100644 index 0000000..3940e5b --- /dev/null +++ b/include/mapbox/geometry/point_arithmetic.hpp @@ -0,0 +1,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 -- cgit