To find the largest incircle radius in a convex package, the radius of the second circle, each side of the convex package to promote the internal R, and then judge whether or not a convex package after propulsion.

#include <iostream> #include <cstdio> #include <string.h> #include <algorithm> #include < math.h> #include <queue> #include <stack> #include <map> #include <vector> #define MM (A,B)
memset (A,b,sizeof (a)) #define MAXN 205 using namespace std;
const int INF=0X7FFFFFF;
Const double Pi=acos (-1.0);
const double eps=1e-7;
const double e=2.7182818284590452354;
struct point {double x,y;
Point () {} point (double x,double y): x (x), Y (y) {}}P[MAXN],Q[MAXN],PNT[MAXN];
int cnt,curcnt,n;
void Initial () {for (int i=1;i<=n;i++) p[i]=pnt[i];
P[N+1]=P[1];
P[0]=p[n];
Cnt=n;
The///two points determine the line void Getline (Point x,point y,double &a,double &b,double &c) {a=y.y-x.y;
b=x.x-y.x;
C=Y.X*X.Y-X.X*Y.Y;
//Intersection point intersect (Point x,point y,double a,double b,double c) {double u=fabs (a*x.x+b*x.y+c);
Double V=fabs (A*Y.X+B*Y.Y+C);
Return point ((v*x.x+u*y.x)/(U+v), (V*X.Y+U*Y.Y)/(U+V); //Straight line cutting void cut (double a,double b,double c) {curcnt=0;
for (int i=1;i<=cnt;i++) {if (a*p[i].x+b*p[i].y+c>=0)//The current point is on the right side of the line q[++curcnt]=p[i];
else {if (a*p[i-1].x+b*p[i-1].y+c>0)//Before a point on the right side of the line Q[++curcnt]=intersect (P[I],P[I-1],A,B,C);
if (a*p[i+1].x+b*p[i+1].y+c>0)//Empathy Q[++curcnt]=intersect (P[I],P[I+1],A,B,C);
for (int i=1;i<=curcnt;i++) p[i]=q[i];
P[CURCNT+1]=P[1];
P[0]=P[CURCNT];
cnt=curcnt;
BOOL Solve (double R) {initial ();
Push inward R for (int i=1;i<=n;i++) {point ta,tb,tt;
TT.X=PNT[I+1].Y-PNT[I].Y;
tt.y=pnt[i].x-pnt[i+1].x;
Double k=r/sqrt (TT.X*TT.X+TT.Y*TT.Y);
Tt.x=tt.x*k;
Tt.y=tt.y*k;
Ta.x=pnt[i].x+tt.x;
Ta.y=pnt[i].y+tt.y;
Tb.x=pnt[i+1].x+tt.x;
Tb.y=pnt[i+1].y+tt.y;
Double a,b,c;
Getline (TA,TB,A,B,C);
Cut (A,B,C);
Return cnt>0?1:0;
int main () {int t; while (~SCANF ("%d", &n), N) {for (int i=1;i<=n;i++) scanf ("%lf%lf", &pnt[i].x,&amP;PNT[I].Y);
for (int i=1;i< (n+1)/2;i++) swap (pnt[i],pnt[n-i));
PNT[N+1]=PNT[1];
Pnt[0]=pnt[n];
Double right=1e9;
Double Left=0,mid;
while (left+eps<right) {mid= (right+left)/2;
if (Solve (mid)) Left=mid;
else Right=mid;
printf ("%lf\n", right);
return 0;
}