87double circle(
const std::vector<Point> &P) {
88 double minR = INFINITY;
95 for (
size_t i = 0; i < P.size() - 2; i++)
97 for (
size_t j = i + 1; j < P.size(); j++)
99 for (
size_t k = j + 1; k < P.size(); k++) {
103 C.x = -0.5 * ((P[i].y * (P[j].x * P[j].x + P[j].y * P[j].y -
104 P[k].x * P[k].x - P[k].y * P[k].y) +
105 P[j].y * (P[k].x * P[k].x + P[k].y * P[k].y -
106 P[i].x * P[i].x - P[i].y * P[i].y) +
107 P[k].y * (P[i].x * P[i].x + P[i].y * P[i].y -
108 P[j].x * P[j].x - P[j].y * P[j].y)) /
109 (P[i].x * (P[j].y - P[k].y) +
110 P[j].x * (P[k].y - P[i].y) +
111 P[k].x * (P[i].y - P[j].y)));
112 C.
y = 0.5 * ((P[i].x * (P[j].x * P[j].x + P[j].y * P[j].y -
113 P[k].x * P[k].x - P[k].y * P[k].y) +
114 P[j].x * (P[k].x * P[k].x + P[k].y * P[k].y -
115 P[i].x * P[i].x - P[i].y * P[i].y) +
116 P[k].x * (P[i].x * P[i].x + P[i].y * P[i].y -
117 P[j].x * P[j].x - P[j].y * P[j].y)) /
118 (P[i].x * (P[j].y - P[k].y) +
119 P[j].x * (P[k].y - P[i].y) +
120 P[k].x * (P[i].y - P[j].y)));
134 for (
size_t i = 0; i < P.size() - 1; i++)
136 for (
size_t j = i + 1; j < P.size(); j++) {
138 C.x = (P[i].x + P[j].x) / 2;
139 C.
y = (P[i].y + P[j].y) / 2;
149 std::cout << minC.x <<
" " << minC.
y << std::endl;