Полностью сделал задачу 6 на вычислительную геометрию

This commit is contained in:
AZEN-SGG 2024-12-21 13:58:46 +03:00
parent a08f95aef8
commit 3efd67c703
15 changed files with 570 additions and 60 deletions

View file

@ -2,49 +2,46 @@
circle hope(point * ps, int length) {
circle crcl;
circle minimum = (circle){(point){0, 0}, 0};
if (length == 1) {
return (circle){ps[0], 0};
} else if (length < 1) {
return minimum;
}
for (int i = 0; i < length; ++i) {
point temp = ps[i];
ps[i] = ps[length - 1];
point temp = ps[0];
for (int i = 1; i < length; ++i) ps[i - 1] = ps[i];
ps[length - 1] = temp;
for (int j = 0; j < length - 1; ++j) {
crcl = centermass(temp, ps[i]);
if (isSuit(crcl, ps, length - 1)) return crcl;
crcl = centermass(temp, ps[j]);
if (isCover(crcl, (points){ps, length}) == length) {
if (minimum.radius < exp || (minimum.radius - crcl.radius > exp)) {
minimum = crcl;
}
}
}
ps[length - 1] = ps[i];
ps[i] = temp;
}
for (int i = 0; i < length; ++i) {
point temp = ps[i];
ps[i] = ps[length - 1];
ps[length - 1] = temp;
for (int j = 0; j < length - 1; ++j) {
temp = ps[j];
ps[j] = ps[length - 2];
ps[length - 2] = temp;
for (int k = 0; k < length - 2; ++k) {
point warp[] = {ps[length - 1], ps[length - 2], ps[k]};
point warp[] = {ps[i], ps[j], ps[k]};
crcl = byThreePoints(warp);
if (fabs(crcl.radius + 1) > exp && isSuit(crcl, ps, length - 2)) return crcl;
if ((fabs(crcl.radius + 1) > exp) && (isCover(crcl, (points){ps, length}) == length)) {
if (minimum.radius < exp || (minimum.radius - crcl.radius > exp)) {
minimum = crcl;
}
}
}
temp = ps[j];
ps[j] = ps[length - 2];
ps[length - 2] = temp;
}
temp = ps[i];
ps[i] = ps[length - 1];
ps[length - 1] = temp;
}
return (circle){.center=(point){0, 0}, .radius=0};
return minimum;
}
bool isSuit(circle crcl, point * ps, int length) {