Convex Hull in C#


A 2D Convex Hull is the smallest convex polygon that encloses a set of 2D points in a plane.


I needed to implement the 2D Convex Hull algorithm for a graph layout algorithm I'm developing.I implemented this in C# for the example, below. Soon, I will be implementing it in Java. 


Below is a randomly-generated unit test case.  Method: Graham's Scan as described in Cormen, Leiserson, et al. This implementation also discards colinear points on the hull. Blue lines are the algorithm 'polar angles' from starting point (magenta). Yellow points are hull points, and orange points are either interior points or discarded midpoints of hull colinear line segments.