1 // Copyright 2023 Google LLC 2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3 4 #ifndef Point_DEFINED 5 #define Point_DEFINED 6 7 #include <cstdint> 8 9 namespace bentleyottmann { 10 struct Point { 11 int32_t x; 12 int32_t y; 13 14 // Relation for ordering events. 15 friend bool operator<(const Point& p0, const Point& p1); 16 friend bool operator>(const Point& p0, const Point& p1); 17 friend bool operator>=(const Point& p0, const Point& p1); 18 friend bool operator<=(const Point& p0, const Point& p1); 19 20 // Equality 21 friend bool operator==(const Point& p0, const Point& p1); 22 friend bool operator!=(const Point& p0, const Point& p1); 23 24 // Extremes 25 static Point Smallest(); 26 static Point Largest(); 27 static bool DifferenceTooBig(Point p0, Point p1); 28 29 // Terms 30 friend Point operator+(const Point& p0, const Point& p1) { 31 return {p0.x + p1.x, p0.y + p1.y}; 32 } 33 friend Point operator-(const Point& p0, const Point& p1) { 34 return {p0.x - p1.x, p0.y - p1.y}; 35 } 36 }; 37 } // namespace bentleyottmann 38 #endif // Point_DEFINED 39