---
id: hull
title: "Convex Hull"
author: Benjamin Qi
description: Smallest convex polygon containing a set of points on a grid.
prerequisites: 
 - Platinum - Geometry Primitives
frequency: 2
---

import { Problem } from "../models";

export const metadata = {
  problems: {
    sample: [
      new Problem("Kattis", "Convex Hull", "convexhull", "Easy", false, ["convex"], ""),
    ],
    sample2: [
      new Problem("Kattis","Robert Hood", "roberthood", "Easy", false, ["convex"], "doesn't require convex hull since coordinates are small"),
    ],
    general: [
      new Problem("Plat", "Balance Beam", "864", "Hard", false, ["convex"], ""),
      new Problem("CF", "Water Balance", "problemset/problem/1299/C", "Easy", false, ["convex"], ""),
      new Problem("CF", "Geometers Anonymous", "problemset/problem/1195/F", "Normal", false, ["convex", "PURS"], ""),
      new Problem("Old Gold", "Cow Curling", "382", "Normal", false, ["convex"], "testing whether points are inside hull"),
      new Problem("AC", "AGC E - Random Pawn", "https://atcoder.jp/contests/agc044/tasks/agc044_e", "Insane", false, ["convex"], ""),
    ],
    rotating: [
      new Problem("Kattis", "Fence Orthogonality", "fenceortho", "Hard", false, ["convex"], "enclosing rectangle"),
    ],
    cht: [
      new Problem("Plat", "Circular Barn", "626", "Hard", false, ["DP", "convex"], ""),
      new Problem("Plat", "Falling Portals", "998", "Very Hard", false, ["convex"], ""),
    ],
  }
};

## [Convex Hull](https://en.wikipedia.org/wiki/Convex_hull_algorithms)

<problems-list problems={metadata.problems.sample} />

### Tutorial

 - Graham Scan
   - [cp-algo](https://cp-algorithms.com/geometry/grahams-scan-convex-hull.html)
   - [My Implementation](https://github.com/bqi343/USACO/blob/master/Implementations/content/geometry%20(13)/Polygons/ConvexHull2.h)
 - Monotone Chain
   - CPH 30.3 (brief)
   - [Wikipedia](https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain)
   - [My Implementation](https://github.com/bqi343/USACO/blob/master/Implementations/content/geometry%20(13)/Polygons/ConvexHull%20(13.2).h)

<problems-list problems={metadata.problems.general} />

## Rotating Caliphers

<problems-list problems={metadata.problems.sample2} />

<resources>
  <resource source="CF" title="Rotating calipers technique and applications" url="blog/entry/46162"> </resource>
</resources>

<problems-list problems={metadata.problems.rotating} />

## Convex Hull Trick

<resources>
  <resource source="cp-algo" title="Convex Hull Trick" url="geometry/convex_hull_trick.html" starred> </resource>
  <resource source="CF" title="Convex Hull Trick - Geo Being Useful" url="blog/entry/63823" starred> </resource>
</resources>

<problems-list problems={metadata.problems.cht} />

https://codeforces.com/contest/1083/problem/E