summaryrefslogtreecommitdiff
path: root/geometry/antipodalPoints.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'geometry/antipodalPoints.cpp')
-rw-r--r--geometry/antipodalPoints.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/geometry/antipodalPoints.cpp b/geometry/antipodalPoints.cpp
new file mode 100644
index 0000000..c1921cc
--- /dev/null
+++ b/geometry/antipodalPoints.cpp
@@ -0,0 +1,13 @@
+vector<pair<int, int>> antipodalPoints(vector<pt>& h) {
+ vector<pair<int, int>> result;
+ int n = (int)h.size();
+ if (n < 2) return result;
+ for (int i = 0, j = 1; i < j; i++) {
+ while (true) {
+ result.push_back({i, j});
+ if (cross(h[(i + 1) % n] - h[i],
+ h[(j + 1) % n] - h[j]) <= 0) break;
+ j = (j + 1) % n;
+ }}
+ return result;
+}