// Calculate the maximum distance from a point in the island with a polygon shape to the sea
// Solution:
// There is a method: Two-Point distance, and then half-side intersection
// Here, we need to pay attention to the precision problem. The length must be from 0 ~ 10 ^ 9 binary (it seems that many pairs of binary lengths are 10 ^ 9), eps 1e-11
// The 212 KB 32 ms code is as follows:
[Cpp]
# Include <iostream>
# Include <cstdio>
# Include <math. h>
# Define eps 1e-11
Using namespace std;
Const int MAXN = 202;
Struct point {double x, y ;};
Point points [MAXN], p [MAXN], q [MAXN];
Int n;
Bool zero (double x)
{
Return x> 0? X <eps: x>-eps;
}
Double xmult (point p1, point p2, point p0)
{
Return (p1.x-Snapshot X) * (p2.y-Snapshot y)-(p2.x-Snapshot X) * (p1.y-Snapshot y );
}
Int same_side (point p1, point p2, point l1, point l2)
{
Return xmult (l1, p1, l2) * xmult (l1, p2, l2)> eps;
}
Point intersection (point p1, point p2, point p3, point p4)
{
Point ret = p1;
Double t = (p1.x-p3.x) * (p3.y-p4.y)-(p3.x-p4.x) * (p1.y-p3.y ))
/(P1.x-p2.x) * (p3.y-p4.y)-(p3.x-p4.x) * (p1.y-p2.y ));
Ret. x + = t * (p2.x-p1.x );
Ret. y + = t * (p2.y-p1.y );
Return ret;
}
Void polygon_cut (int & n, point * p, point l1, point l2, point side)
{
Point pp [2, 1000];
Int m = 0, I;
For (I = 0; I <n; I ++)
{
If (same_side (p [I], side, l1, l2 ))
Pp [m ++] = p [I];
If (! Same_side (p [I], p [(I + 1) % n], l1, l2)
&&! (Zero (xmult (p [I], l1, l2 ))
& Zero (xmult (p [(I + 1) % n], l1, l2 ))))
Pp [m ++] = intersection (p [I], p [(I + 1) % n], l1, l2 );
}
N = 0;
For (I = 0; I <m; I ++)
If (! I |! Zero (pp [I]. x-pp [I-1]. x) |! Zero (pp [I]. y-pp [I-1]. y ))
P [n ++] = pp [I];
If (zero (p [n-1]. x-p [0]. x) & zero (p [n-1]. y-p [0]. y ))
N --;//
}
Double distance (point p1, point p2)
{
Return sqrt (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y ));
}
Void slove (double dis, int & m)
{
Int I;
For (I = 0; I <n; I ++)
{
Point side;
// Inwards forward dis
Point s = points [I], e = points [(I + 1) % n];
Double xx = e. x-s.x, yy = e. y-s.y;
Double dd = sqrt (xx * xx + yy * yy );
S. x + = dis * (-yy)/dd;
S. y + = dis * (xx)/dd;
E. x + = dis * (-yy)/dd;
E. y + = dis * (xx)/dd;
Side. x = s. x-yy;
Side. y = s. y + xx;
Polygon_cut (m, p, s, e, side );
}
}
Double two (double l, double r)
{
Double mid = (l + r)/2.0;
If (r-l <eps) return mid;
Int I;
For (I = 0; I <n; I ++) p [I] = points [I];
Int m = n;
Slove (mid, m );
If (m <3) return two (l, mid );
Else
{
Return two (mid, r );
}
}
Int main ()
{
While (scanf ("% d", & n), n)
{
Int I;
For (I = 0; I <n; I ++)
{
Scanf ("% lf", & points [I]. x, & points [I]. y );
}
Double res = 0.0;
Res = two (0 );
Printf ("%. 6lf \ n", res );
}
Return 0;
}
Author: ssslpk