// Copyright 2023 Google LLC // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. #include "modules/bentleyottmann/include/Point.h" #include #include namespace bentleyottmann { // -- Point ---------------------------------------------------------------------------------------- bool operator<(const Point& p0, const Point& p1) { return std::tie(p0.y, p0.x) < std::tie(p1.y, p1.x); } bool operator>(const Point& p0, const Point& p1) { return p1 < p0; } bool operator>=(const Point& p0, const Point& p1) { return !(p0 < p1); } bool operator<=(const Point& p0, const Point& p1) { return !(p0 > p1); } bool operator==(const Point& p0, const Point& p1) { return std::tie(p0.y, p0.x) == std::tie(p1.y, p1.x); } bool operator!=(const Point& p0, const Point& p1) { return !(p0 == p1); } Point Point::Smallest() { const int32_t kMinCoordinate = std::numeric_limits::min(); return {kMinCoordinate, kMinCoordinate}; } Point Point::Largest() { const int32_t kMaxCoordinate = std::numeric_limits::max(); return {kMaxCoordinate, kMaxCoordinate}; } bool Point::DifferenceTooBig(Point p0, Point p1) { auto tooBig = [](int32_t a, int32_t b) { return (b > 0 && a < std::numeric_limits::min() + b) || (b < 0 && a > std::numeric_limits::max() + b); }; return tooBig(p0.x, p1.x) || tooBig(p0.y, p1.y); } } // namespace bentleyottmann