Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using Point = complex<double>;
- Point perp(Point p) { return {-p.imag(), p.real()}; }
- int main() {
- ifstream cin("expand.in");
- ofstream cout("expand.out");
- int _t, n; double r;
- cin >> _t >> n >> r; r += 1e-7;
- vector<Point> pts;
- for (int i = 0; i < n; ++i) {
- double x, y; cin >> x >> y;
- pts.emplace_back(x, y);
- }
- vector<Point> sol = pts;
- for (int it = 0; it < 300; ++it) {
- int idx = it % n;
- Point a = sol[(idx + n - 1) % n], b = sol[(idx + 1) % n];
- Point ref = pts[idx];
- Point d = perp(b - a);
- sol[idx] = ref - d / abs(d) * r;
- }
- cout << fixed << setprecision(20);
- for (int i = 0; i < n; ++i)
- cout << sol[i].real() << " " << sol[i].imag() << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement