The study calls for organizing the traps in which moths have been caught into compact regions, which will then be used to test each eradication program. A region is defined as the polygon with the minimum length perimeter that can enclose all traps within that region. For example, the traps (represented by dots) of a particular region and its associated polygon are illustrated below.
You must write a program that can take as input the locations of traps in a region and output the locations of traps that lie on the perimeter of the region as well as the length of the perimeter.
One blank line must separate output from consecutive input records.
- First line
- The number of the region. (The first record corresponds to region #1, the second to region #2, etc.)
- Next line(s):
- A listing of all the points that appear on the perimeter of the region. The points must be identified in the standard form "(x-coordinate,y-coordinate)" rounded to a single decimal place. The starting point for this listing is irrelevant, but the listing must be oriented clockwise and begin and end with the same point. For collinear points, any order which describes the minimum length perimeter is acceptable.
- Last line:
- The length of the perimeter of the region rounded to 2 decimal places.
A sample input file with records for 3 regions followed by correct output for the sample input is shown below.
3 1 2 4 10 5 12.3 6 0 0 1 1 3.1 1.3 3 4.5 6 2.1 2 -3.2 7 1 0.5 5 0 4 1.5 3 -0.2 2.5 -1.5 0 0 2 2 0
Region #1: (1.0,2.0)-(4.0,10.0)-(5.0,12.3)-(1.0,2.0) Perimeter length = 22.10 Region #2: (0.0,0.0)-(3.0,4.5)-(6.0,2.1)-(2.0,-3.2)-(0.0,0.0) Perimeter length = 19.66 Region #3: (0.0,0.0)-(2.0,2.0)-(4.0,1.5)-(5.0,0.0)-(2.5,-1.5)-(0.0,0.0) Perimeter length = 12.52