Given a random set of points in 2D space such as:

How would one go about finding the smallest perimeter polygon that encompasses all points and has a point as each one of its vertices? For the above diagram the polygon would be:

Given a random set of points in 2D space such as:

How would one go about finding the smallest perimeter polygon that encompasses all points and has a point as each one of its vertices? For the above diagram the polygon would be:

On
A convex hull has the property that every inner point is contained in some triangle from the hull, and no point on the hull is. So we need to cycle through the available triangles looking for inner points and remove them. This can be done by considering triangles two sides at a time. We can find the angles using the dot product rule, and note there are 3 cases, two for outside the angle and 1 for inside. If a point passes this test for all 3 cases, the point is inside the triangle. Alternatively draw a line from every point to every other point, and use some system of fills (if you only want a graphical solution). Note that finding a bounding rectangle is trivial.
This problem can be solved using the Graham scan. How does it work?
This is how the Graham scan works - my explanation is really simplified, but you'll find the detailed mechanism explanation on the Wikipedia page.