ans;
int tot = CircleThroughAPointAndTangentToALineWithRadius(p[0], p[1], p[2] - p[1], r[0], ans);
sort(ans.begin(), ans.end());
printf("[");
for (int i = 0; i < tot; i++) {
printf("(%.6f,%.6f)", ans[i].x, ans[i].y);
if (i != tot - 1) printf(",");
}
printf("]\n");
} else if (strcmp(op, "CircleTangentToTwoLinesWithRadius") == 0) {
Point ans[4];
for (int i = 0; i < 4; i++) p[i].read();
scanf("%lf", &r[0]);
int tot = CircleThroughAPointAndTangentALineWithRadius(p[0], p[1] - p[0], p[3], p[3] - p[2], r[0], ans);
sort(ans, ans + tot);
printf("[");
for (int i = 0; i < tot; i++) {
printf("(%.6f,%.6f)", ans[i].x, ans[i].y);
if (i != tot - 1) printf(",");
}
printf("]\n");
} else {
p[0].read(); scanf("%lf", &r[0]);
p[1].read(); scanf("%lf", &r[1]);
scanf("%lf", &r[2]);
Point ans[4];
int tot = CircleTangentToTwoDisjointCirclesWithRadius(Circle(p[0], r[0]), Circle(p[1], r[1]), r[2], ans);
sort(ans, ans + tot);
printf("[");
for (int i = 0; i < tot; i++) {
printf("(%.6f,%.6f)", ans[i].x, ans[i].y);
if (i != tot - 1) printf(",");
}
printf("]\n");
}
}
return 0;
}计算几何-圆 模板 训练指南267
原文:http://www.cnblogs.com/smilesundream/p/5281519.html