A certain deadly virus suddenly appears within a small country. In order to contain this virus, the government implements a very simple quarantine protocol. They build a wall to contain the affected areas.
Here
is a list of the coordinates of all the affected areas. Suppose the wall encloses some polygonal area with the smallest possible perimeter, what is the area of the polygon?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
To determine which points in the list make up the vertices of the containment polygon, I first put all the points (x,y) into a 2 dimensional array and sorted with respect to the x value. I then start with the first element of the array (the leftmost point), and determine the slope between it and each of the other points.
The largest slope will be with the next point along the top half of the polygon, and the smallest slope will be the next point along the bottom. I then add those to a list. Then I take the next point along the top, and search all the points after it in the array (to the right graphically), and find the next largest slope, and add it as being the next point along the top. I repeat this with the bottom, and perform this step over and over until I reach the last element in the array for both the top and bottom halves of the polygon.
After I have the points that make up the top and bottom halves of the polygon, I find the integral of the shape formed by the top half of the polygon from the range of the first element in the array to the last (still talking x values here), and subtract from that the integral of the bottom half of the polygon.
I found the integral of the halves using trapezoidal sums. Here's the formula for the integral between point 1 and point 2:
i n t e g r a l = 2 ( x 2 − x 1 ) × ( y 2 + y 1 )