其他分享
首页 > 其他分享> > 点

作者:互联网

#include <bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
#define scan(i) scanf("%d",&i)
#define pf printf
using namespace std;
const  double eps=1e-10;
const double PI=acos(-1.0);
using namespace std;
struct Point{
    double x;
    double y;
    Point(double x=0,double y=0):x(x),y(y){}
    void operator<<(Point &A) {cout<<A.x<<' '<<A.y<<endl;}
    bool operator!=(Point &A) {if(fabs(A.x-x)>eps||fabs(A.y-y)>eps) return true;return false;}
};

int dcmp(double x)  {return (x>eps)-(x<-eps); }
int sgn(double x)  {return (x>eps)-(x<-eps); }
typedef  Point  Vector;

Vector  operator +(Vector A,Vector B) { return Vector(A.x+B.x,A.y+B.y);}
Vector  operator -(Vector A,Vector B) { return Vector(A.x-B.x,A.y-B.y); }
Vector  operator *(Vector A,double p) { return Vector(A.x*p,A.y*p);  }
Vector  operator /(Vector A,double p) {return Vector(A.x/p,A.y/p);}
ostream &operator<<(ostream & out,Point & P) { out<<P.x<<' '<<P.y<<endl; return out;}
bool  operator< (const Point &A,const Point &B) { return dcmp(A.x-B.x)<0||(dcmp(A.x-B.x)==0&&dcmp(A.y-B.y)<0); }
bool  operator== ( const Point &A,const Point &B) { return dcmp(A.x-B.x)==0&&dcmp(A.y-B.y)==0;}

double  Dot(Vector A,Vector B) {return A.x*B.x+A.y*B.y;}
double  Cross(Vector A,Vector B)  {return A.x*B.y-B.x*A.y; }
double  Length(Vector A)  { return sqrt(Dot(A, A));}
double  Angle(Vector A,Vector B) {return acos(Dot(A,B)/Length(A)/Length(B));}
double  Area2(Point A,Point B,Point C ) {return fabs(Cross(B-A, C-A));}

Vector Rotate(Vector A,double rad) { return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));}
Vector Normal(Vector A) {double L=Length(A);return Vector(-A.y/L,A.x/L);}

Point GetLineIntersection(Point P,Vector v,Point Q,Vector w){
    if(v.x*w.y==v.y*w.x) return Point(5201314,5201314);
    Vector u=P-Q;
    double t=Cross(w, u)/Cross(v,w);
    return P+v*t;
}//输入两个点斜式方程输出交点

bool  OnSegment(Point P,Point A,Point B){
    return dcmp(Cross(P-A, P-B))==0&&dcmp(Dot(P-A,P-B))<=0;
}//输入三个点,判断P是否在线段AB上

  

标签:,return,fabs,int,eps,long,define
来源: https://www.cnblogs.com/Macb3th/p/15539963.html