Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Point.cpp
Go to the documentation of this file.
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
5
6#include <limits>
7#include <tuple>
8
9namespace bentleyottmann {
10
11// -- Point ----------------------------------------------------------------------------------------
12bool operator<(const Point& p0, const Point& p1) {
13 return std::tie(p0.y, p0.x) < std::tie(p1.y, p1.x);
14}
15
16bool operator>(const Point& p0, const Point& p1) {
17 return p1 < p0;
18}
19
20bool operator>=(const Point& p0, const Point& p1) {
21 return !(p0 < p1);
22}
23
24bool operator<=(const Point& p0, const Point& p1) {
25 return !(p0 > p1);
26}
27
28bool operator==(const Point& p0, const Point& p1) {
29 return std::tie(p0.y, p0.x) == std::tie(p1.y, p1.x);
30}
31
32bool operator!=(const Point& p0, const Point& p1) {
33 return !(p0 == p1);
34}
35
37 const int32_t kMinCoordinate = std::numeric_limits<int32_t>::min();
38 return {kMinCoordinate, kMinCoordinate};
39}
40
42 const int32_t kMaxCoordinate = std::numeric_limits<int32_t>::max();
43 return {kMaxCoordinate, kMaxCoordinate};
44}
45
47 auto tooBig = [](int32_t a, int32_t b) {
48 return (b > 0 && a < std::numeric_limits<int32_t>::min() + b) ||
49 (b < 0 && a > std::numeric_limits<int32_t>::max() + b);
50 };
51
52 return tooBig(p0.x, p1.x) || tooBig(p0.y, p1.y);
53}
54} // namespace bentleyottmann
static bool b
struct MyStruct a[10]
bool operator>=(const Point &p0, const Point &p1)
Definition Point.cpp:20
bool operator<(const Int96 &a, const Int96 &b)
Definition Int96.cpp:23
bool operator!=(const Point &p0, const Point &p1)
Definition Point.cpp:32
bool operator<=(const Point &p0, const Point &p1)
Definition Point.cpp:24
bool operator==(const Int96 &a, const Int96 &b)
Definition Int96.cpp:19
friend bool operator>(const Point &p0, const Point &p1)
Definition Point.cpp:16
static Point Smallest()
Definition Point.cpp:36
static bool DifferenceTooBig(Point p0, Point p1)
Definition Point.cpp:46
static Point Largest()
Definition Point.cpp:41