#include<complex>
#define sqr(x) ((x)*(x))
#define LL long long
#define INF 0x3f3f3f3f
const double PI = acos(-1.0);
const double eps = 1e-8;
#define maxm 210010
#define maxn 110
using namespace std;
struct Point{
double x,y;
Point(double x = 0, double y = 0) : x(x),y(y){}
};
typedef Point Vector;
Vector operator + (Point A, Point B) {return Vector(A.x + B.x,A.y+B.y);}
Vector operator - (Point A, Point 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);}
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 - A.y*B.x;}
double Length(Vector A) {return sqrt(Dot(A,A));}
double Angle(Vector A, Vector B) {return acos(Dot(A,B) / Length(A)/Length(B));}
//线段
struct Segment
{
Point a,b;
}S[maxn];
//复数表示
//double Dot(Vector A, Vector B) {return real(conj(A)*B);}
//double Cross(Vector A,Vector B) {return imag(conj(A)*B);}
//double Rotate(Vector A, Vector B) {return A*exp(Point(0,read));}
//判断点是否重合
bool check(Point A, Point B)
{
double d = sqrt((A.x-B.x)*(A.x-B.x) + (A.y - B.y)*(A.y-B.y));
if(d < eps) return true;
else return false;
}
//直线交点
Point GetlineIntersection(Point P, Vector v, Point Q, Vector w)
{
Vector u = P - Q;
double t = Cross(w,u)/Cross(v,w);
return P + v*t;
}
//判断三点是否共线
bool judge(Point A, Point B, Point C)
{
Vector p = A - B;
Vector q = C - B;
if(abs(Cross(p,q)) < eps)
return true;
}
计算几何 —— 模板
最新推荐文章于 2021-05-22 18:58:54 发布