In these fast-paced times, companies are investing in heliports to reduce travel time for their busy executives. The heliports are typically circular landing pads, constructed on the roofs of the companies' headquarters.
You must write a program that finds the largest radius for a circular heliport that can be constructed on the flat roof of a building that is in the form of a simple polygon. Since this is merely the design phase of the construction effort, your program must find only the radius of the heliport. The maximum radius for a heliport in the diagram shown is 10.
Input for the last test case is followed by a line consisting of the number 0.
4 2 R 2 U 2 L 2 D 10 10 R 10 U 10 L 10 U 10 R 5 U 30 L 20 D 20 R 5 D 0
Case Number 1 radius is: 1.00 Case Number 2 radius is: 10.00
#include
#include
const double eps=1e-6;
int x[25],y[25],n,i,len,px,py,cases;
double ra,rb,r;
char dr;
bool check(double ox,double oy)
{
int i,s;
s=0;
for(i=0;iox && ((y[i]>oy)^(y[i+1]>oy))) s++;
if(s%2==0)
return false;
for(i=0;ioy)^(y[i+1]>oy))&&fabs(x[i]-ox)ox)^(x[i+1]>ox))&&fabs(y[i]-oy)0&&dieps)
{
r=(ra+rb)/2;
if(ok())
ra=r;
else
rb=r;
}
printf("Case Number %d radius is: %.2lf\n",++cases,r);
}
return 0;
}