コード例 #1
0
double calc(const Point &a, const Point &b, const Point &c) {
    double max_top = -1.0;
    for (int lower=0; lower<2; ++lower) {
        {
            const Circle C(a, b, R, lower);
            if (C.is_valid() && C.is_inside(c)) {
                max_top = max(max_top, C.top());
            }
        }
        {
            const Circle C(a, c, R, lower);
            if (C.is_valid() && C.is_inside(b)) {
                max_top = max(max_top, C.top());
            }
        }
        {
            const Circle C(c, b, R, lower);
            if (C.is_valid() && C.is_inside(a)) {
                max_top = max(max_top, C.top());
            }
        }
    }
    {
        const Circle C(a, Point(a.x, a.y+2*R), R, 0);
        if (C.is_valid() && C.is_inside(b) && C.is_inside(c)) {
            max_top = max(max_top, C.top());
        }
    }
    {
        const Circle C(b, Point(b.x, b.y+2*R), R, 0);
        if (C.is_valid() && C.is_inside(a) && C.is_inside(c)) {
            max_top = max(max_top, C.top());
        }
    }
    {
        const Circle C(c, Point(c.x, c.y+2*R), R, 0);
        if (C.is_valid() && C.is_inside(a) && C.is_inside(b)) {
            max_top = max(max_top, C.top());
        }
    }
    return max_top;
}
コード例 #2
0
bool ok(const Point &a, const Point &b, const Point &c) {
    for (int lower=0; lower<2; ++lower) {
        {
            const Circle C(a, b, R, lower);
            if (C.is_valid() && C.bottom()<EPS && C.is_inside(c)) {
                return true;
            }
        }
        {
            const Circle C(a, c, R, lower);
            if (C.is_valid() && C.bottom()<EPS && C.is_inside(b)) {
                return true;
            }
        }
        {
            const Circle C(b, c, R, lower);
            if (C.is_valid() && C.bottom()<EPS && C.is_inside(a)) {
                return true;
            }
        }
        {
            const Circle C(a, Point(a.x, 0), R, lower);
            if (C.is_valid() && C.is_inside(b) && C.is_inside(c)) {
                return true;
            }
        }
        {
            const Circle C(b, Point(b.x, 0), R, lower);
            if (C.is_valid() && C.is_inside(a) && C.is_inside(c)) {
                return true;
            }
        }
        {
            const Circle C(c, Point(c.x, 0), R, lower);
            if (C.is_valid() && C.is_inside(a) && C.is_inside(b)) {
                return true;
            }
        }
    }
    
    return false;
}