//Mon Nov 12 00:03:48 JST 2007 #include #include #include #include #include using namespace std; const int infinity = 1 << 29; const double eps = 1e-10; struct Point{ int x, y; Point(int a, int b): x(a), y(b){} }; // //returns int ccw(const Point & p, const Point & q, const Point & r){ int dx, dy, dx_, dy_; dx = q.x - p.x; dy = q.y - p.y; dx_ = r.x - p.x; dy_ = r.y - p.y; return dx * dy_ - dy * dx_; } //set of three struct Triplet{ int a, b, c; Triplet(int x = 0, int y = 0, int z = 0):a(x), b(y), c(z){} }; struct Parallel{ }; struct Error{ }; struct Line{ Point p1, p2; //trans Line presentation from //'the line connects p1 and p2' to //'the line is ax + by = c' Triplet transToTriplet() const { int dx = p2.x - p1.x; int dy = p2.y - p1.y; return Triplet(-dy, dx, p1.y * dx - dy * p1.x); } Line(const Point &p, const Point & q): p1(p), p2(q){} }; std::pair > intersectionOf(const Triplet & p, const Triplet & q){ //determinant int det = p.a * q.b - p.b * q.a; if(det == 0){throw Parallel();} //multiply inverse matrix int x = q.b * p.c - p.b * q.c; int y = p.a * q.c - q.a * p.c; return std::make_pair(det, std::make_pair(x, y)); } int round_to_int(double x){ int X = (int)(round(x)); return abs(X - x) < eps ? X: infinity; } int getYB(int x2, int y2, int xa, int ya, int xb, int sign){ int dx = xa - x2; int dy = ya - y2; int d = dx * dx + dy * dy; int dx_ = xb - x2; if(d - dx_ * dx_ < 0){return infinity;} int dy_ = round_to_int(sqrt(d - dx_ * dx_)); if(dy_ == infinity){return infinity;} int yb = y2 - sign * dy_; return yb; } double isValid(Point p1, Point p2, Point p3, Point pa, Point pb, Point pc){ if(ccw(p1, p2, pa) >= 0){return false;} if(ccw(p2, p3, pb) >= 0){return false;} if(ccw(p3, p1, pc) >= 0){return false;} return true; } long long sqrt2p(long long x, long long y){ return x * x + y * y; } std::complex getD(Point p1, Point p2, Point p3, Point pa, Point pb, Point pc){ Line l12(p1, p2); Line l23(p2, p3); Triplet t12 = l12.transToTriplet(); Triplet t23 = l23.transToTriplet(); Triplet nt12, nt23; nt12.a = t12.b; nt12.b = -t12.a; nt12.c = nt12.a * pa.x + nt12.b * pa.y; nt23.a = t23.b; nt23.b = -t23.a; nt23.c = nt23.a * pb.x + nt23.b * pb.y; std::pair > d = intersectionOf(nt12, nt23); int m = d.first; int dx = d.second.first; int dy = d.second.second; long long D = sqrt2p((pa.x - p1.x), (pa.y - p1.y)) * m * m; long long D_ = sqrt2p(dx - p1.x * m, dy - p1.y * m); if(D <= D_){ throw Error(); } return std::complex((double)dx / m, (double)dy / m); } int main(){ while(true){ int x1, x2, y1, y2, x3, y3; std::scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3); if(x1 == 0 and y1 == 0 and x2 == 0 and y2 == 0 and x3 == 0 and y3 == 0){ break; } Point p1(x1, y1), p2(x2, y2), p3(x3, y3); std::complex z1(x1, y1), z2(x2, y2), z3(x3, y3); double mh = 1e+10; for(int xa = -100; xa <= 100; xa++){ for(int ya = -100; ya <= 100; ya++){ Point pa(xa, ya); if(ccw(p1, p2, pa) > 0){continue;} std::complex za(xa, ya); int mxb = (int)(std::max(-100.0, x2 - std::abs(za - z2)) - 1); int Mxb = (int)(std::min(100.0, x2 + std::abs(za - z2)) + 1); for(int xb = mxb; xb <= Mxb; xb++){ for(int k = 0; k < 2; k++){ int yb = getYB(x2, y2, xa, ya, xb, k == 0 ? 1: -1); if(yb == infinity or std::abs(yb) > 100){continue;} Point pb(xb, yb); if(ccw(p2, p3, pb) > 0){continue;} assert(sqrt2p(xa - x2, ya - y2) == sqrt2p(xb - x2, yb - y2)); std::complex zb(xb, yb); double C = std::norm(za - z1) + std::norm(z3 - z1) - std::norm(zb - z3); double theta = std::acos(C / 2.0 / std::abs(za - z1) / std::abs(z3 - z1)); std::complex w(0, theta); std::complex zc = (z3 - z1) / std::abs(z3 - z1) * std::exp(w) * std::abs(z1 - za) + z1; std::complex zc_ = (z3 - z1) / std::abs(z3 - z1) / std::exp(w) * std::abs(z1 - za) + z1; int xcs[] = {round_to_int(zc.real()), round_to_int(zc_.real())}; int ycs[] = {round_to_int(zc.imag()), round_to_int(zc_.imag())}; for(int i = 0; i < 2; i++){ Point pc(xcs[i], ycs[i]); if(pc.x == infinity or pc.y == infinity or std::abs(pc.x) > 100 or std::abs(pc.y) > 100 or not isValid(p1, p2, p3, pa, pb, pc)){ continue; } assert(sqrt2p(pb.x - p3.x, pb.y - p3.y) == sqrt2p(pc.x - p3.x, pc.y - p3.y)); assert(sqrt2p(pc.x - p1.x, pc.y - p1.y) == sqrt2p(pa.x - p1.x, pa.y - p1.y)); try{ std::complex d = getD(p1, p2, p3, pa, pb, pc); mh = std::min(mh, std::sqrt(std::norm(za - z1) - std::norm(d - z1))); }catch(...){} } } } } } if(mh < 1e+10){ std::printf("%.7f\n", mh); }else{ std::printf("-1\n"); } } }