cplib

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub NEET-6z/cplib

:warning: src/geometry/base.hpp

Depends on

Code

#include "../template.hpp"


using ld=long double;
using P=complex<ld>;
const ld EPS=1e-12;
const ld PI=acos(-1.0L);

ld dot(P a,P b){return (conj(a)*b).real();}
ld cross(P a,P b){return (conj(a)*b).imag();}
P rotate(P p,ld r){
    return p*polar(1.0L,r);
}
int sign(ld r){
    if(EPS<r) return 1;
    if(r<-EPS) return -1;
    return 0;
}
bool eq(ld a,ld b){
    return (sign(a-b)==0);
}

int ccw(P a,P b,P c){
    b-=a;c-=a;
    if(cross(b,c)>EPS) return 1;   // counter-clockwise(反時計)
    if(cross(b,c)<-EPS) return -1;   // clockwise(時計)
    if(dot(b,c)<-EPS) return 2;   // c-a-b
    if(norm(b)<norm(c)) return -2;  // a-b-c
    return 0; // a-c-b
}

P unitvector(P a){return a/abs(a);}
P normalvector(P a){return a*P(0,1);}
ld radtodeg(ld rad){return rad*180/PI;}
ld degtorad(ld deg){return deg*PI/180;}
ld angle(P a,P b){return atan2l(cross(a,b),dot(a,b));}

bool operator<(P a,P b){
    if(sign(a.real()-b.real())) return sign(a.real()-b.real())<0;
    return sign(a.imag()-b.imag())<0;
}
#line 2 "src/template.hpp"
#include <bits/stdc++.h>
using namespace std;
#define si(a) (long)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename S,typename F> bool chmin(S&a,F b){return b<a?(a=b,1):0;}
template<typename S,typename F> bool chmax(S&a,F b){return b>a?(a=b,1):0;}
bool _=(ios::sync_with_stdio(0),cin.tie(0),cout<<fixed<<setprecision(16),0);
#line 2 "src/geometry/base.hpp"


using ld=long double;
using P=complex<ld>;
const ld EPS=1e-12;
const ld PI=acos(-1.0L);

ld dot(P a,P b){return (conj(a)*b).real();}
ld cross(P a,P b){return (conj(a)*b).imag();}
P rotate(P p,ld r){
    return p*polar(1.0L,r);
}
int sign(ld r){
    if(EPS<r) return 1;
    if(r<-EPS) return -1;
    return 0;
}
bool eq(ld a,ld b){
    return (sign(a-b)==0);
}

int ccw(P a,P b,P c){
    b-=a;c-=a;
    if(cross(b,c)>EPS) return 1;   // counter-clockwise(反時計)
    if(cross(b,c)<-EPS) return -1;   // clockwise(時計)
    if(dot(b,c)<-EPS) return 2;   // c-a-b
    if(norm(b)<norm(c)) return -2;  // a-b-c
    return 0; // a-c-b
}

P unitvector(P a){return a/abs(a);}
P normalvector(P a){return a*P(0,1);}
ld radtodeg(ld rad){return rad*180/PI;}
ld degtorad(ld deg){return deg*PI/180;}
ld angle(P a,P b){return atan2l(cross(a,b),dot(a,b));}

bool operator<(P a,P b){
    if(sign(a.real()-b.real())) return sign(a.real()-b.real())<0;
    return sign(a.imag()-b.imag())<0;
}
Back to top page