Language: C++

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

const double EPS = 1e-6, PI = acos(-1.0);

inline bool eq(double a, double b) { return fabs(b - a) < EPS; }

struct Point
{
  double x, y;

  Point() {}

  Point(double x, double y) : x(x), y(y) {}

  Point operator+(const Point &b) const { return Point(x + b.x, y + b.y); }

  Point operator-(const Point &b) const { return Point(x - b.x, y - b.y); }

  Point operator*(const double b) const { return Point(x * b, y * b); }

  Point operator*(const Point &b) const { return Point(x * b.x - y * b.y, x * b.y + y * b.x); }

  Point operator/(const double b) const { return Point(x / b, y / b); }

  bool operator<(const Point &b) const { return x != b.x ? x < b.x : y < b.y; }

  bool operator==(const Point &b) const { return eq(x, b.x) && eq(y, b.y); }

  double norm() { return x * x + y * y; }

  double arg() { return atan2(x, y); }

  double abs() { return sqrt(norm()); }

  Point rotate(double theta) { return Point(cos(theta) * x - sin(theta) * y, sin(theta) * x + cos(theta) * y); }

  Point rotate90() { return Point(-y, x); }

  friend ostream &operator<<(ostream &os, Point &p) { return os << "(" << p.x << "," << p.y << ")"; }

  friend istream &operator>>(istream &is, Point &a) { return is >> a.x >> a.y; }
};

double cross(const Point &a, const Point &b)
{
  return a.x * b.y - a.y * b.x;
}


typedef vector< Point > Polygon;

Polygon Convex_Hull(Polygon& p){
    int n = p.size(), k = 0;
    if(n >= 3){
      sort(p.begin(), p.end());
      vector< Point > ch(2 * n);
      for(int i = 0; i < n; ch[k++] = p[i++]){
        while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
      }
      for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]){
        while(k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
      }
      ch.resize(k - 1);
      return ch;
    } else {
      return p;
    }
}

signed main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    Polygon po;
    map<P, int> mp;
    rep(i, 0, n){
        cin >> x[i] >> y[i];
        mp[P(x[i], y[i])] = i;
        po.push_back(Point(x[i], y[i]));
    }
    if(n == 2){
        cout << 0.5 << endl << 0.5 << endl;
        return 0;
    }
    Polygon ch = Convex_Hull(po);
    vector<double> ans(n, 0.0);
    int sz = ch.size();
    rep(i, 0, ch.size()){
        Point now = ch[i];
        Point pre = ch[(i - 1 + sz) % sz];
        Point next = ch[(i + 1) % sz];
        // double d1 = (now.y - pre.y) / (now.x - pre.x);
        // double d2 = (next.y - now.y) / (next.x - now.x);
        int id = mp[P((int)now.x, (int)now.y)];
        // double m1 = -1.0 / d1;
        // double m2 = -1.0 / d2;
        double m1;
        double m2;
        if(fabs(now.y - pre.y) < EPS) m1 = INF;
        else m1 = -(now.x - pre.x) / (now.y - pre.y);
        if(fabs(next.y - now.y) < EPS) m2 = INF;
        else m2 = -(next.x - now.x) / (next.y - now.y);
        // cout << d1 << ' ' << d2 << ' ' << m1 << ' ' << m2 << endl;     
        double tn, tmp;
        if(fabs(m1 * m2 + 1.0) < EPS){
            tmp = 0.250000000;
        }else if(fabs(m2) > 1e9 || fabs(m1) > 1e9){
            if(fabs(m1) > 1e9){
                double th1 = -PI / 2.0;
                if(m1 > 1e9) th1 = PI / 2.0;
                double th2 = atan(m2);
            }else{
                double th2 = -PI / 2.0;
                if(m2 > 1e9) th2 = PI / 2.0;
                double th1 = atan(m1);
            }
            tmp = (th2 - th1) / (2.0 * PI);
        }else{
            tn = (m2 - m1) / (1.0 + m1 * m2);
            tmp = atan(tn) / (2.0 * PI);
            if(tn < -EPS){
                tmp = (atan(tn) + PI) / (2.0 * PI);
            }
        }
        ans[id] = tmp;
    }
    rep(i, 0, n){
        printf("%.15f\n", ans[i]);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:128:20: error: 'th2' was not declared in this scope
  128 |             tmp = (th2 - th1) / (2.0 * PI);
      |                    ^~~
a.cc:128:26: error: 'th1' was not declared in this scope
  128 |             tmp = (th2 - th1) / (2.0 * PI);
      |                          ^~~