自己手打的模板
来源:互联网 发布:电脑语音输入软件 编辑:程序博客网 时间:2024/04/30 12:49
#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <cmath>#include <cstdlib>#include <string>#include <map>#include <vector>#include <set>#include <queue>#include <stack>#include <cctype>using namespace std;#define ll long longtypedef unsigned long long ull;#define maxn 10010#define INF 1<<30struct Point{ double x,y; Point(double x = 0, double y = 0):x(x),y(y) {}};typedef Point Vector ;Vector operator + (Vector A, Vector B){ return Vector(A.x + B.x, A.y + B.y);}Vector operator - (Vector 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);}Vector operator / (Vector A, double p){return Vector(A.x / p, A.y / p);}bool operator < (const Point & a, const Point & b){ return a.x < b.x || (a.x == b.x && a.y < b.y);}const double eps = 1e-10;int dcmp(double x){ if(fabs(x) < eps) return 0; else return x < 0 ? -1 : 1;}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 Length(Vector A) { return sqrt(Dot(A, A));} //向量长度double Angle(Vector A, Vector B){ return acos(Dot(A, B)/Length(A)/Length(B));} //夹角double Cross(Vector A, Vector B){return A.x*B.y - A.y * B.x;} //叉积(面积两倍)double Area2(Point A, Point B, Point C){return 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));}<span style="font-family: Arial, Helvetica, sans-serif;">// 旋转后的直线</span> Vector Normal(Vector A){ double L = Length(A); return Vector(-A.y/L, A.x/L);}Point GetLineIntersection(Point P, Point v, Point Q, Point w){ //求直线 pv 与qw的交点 Vector u = P-Q; double t = Cross(w, u) / Cross(v, w); return P+v*t;} double DistanceToline(Point P, Point A, Point B){ //点到直线的距离 Vector v1 = B - A,v2 = P - A; return fabs(Cross(v1,v2))/Length(v1);}double DistanceTpsegment(Point P, Point A, Point B){ //点到线段的距离 if(A == B) return Length(P-A); Vector v1 = B - A, v2 = P - A, v3 = P - B; if(dcmp(Dot(v1, v2)) < 0) return Length(v2); else if(dcmp(Dot(v1,v3)) > 0) return Length(v3); else return fabs(Cross(v1, v2)) / Length(v1);}Point GetLinePrijection(Point P, Point A, Point B){ // 点在直线上的投影 Vector v = B-A; return A+v*(Dot(v, P-A)/Dot(v,v));}bool SegmentProperIntersection(Point a1, Point a2, Point b1, Point b2){ // 线段相交判定(不包括在端点处的情况) double c1 = Cross(a2 - a1,b1-a1) ,c2 = Cross(a2 - a1,b2-a1), c3 = Cross(b2 - b1, a1-b1), c4 = Cross(b2 - b1, a2 - b1); return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3)*dcmp(c4) < 0;}bool OnSegment(Point p, Point a1, Point a2){ //线段在端点处是否可能相交 return dcmp(Cross(a1-p, a2-p)) == 0 && dcmp(Dot(a1-p, a2-p)) < 0;}double ConvexPolygonArea(Point * p,int n){ // 多边形的有向面积 double area = 0; for(int i = 1; i < n-1; i++) area += Cross(p[i] - p[0],p[i+1] - p[0]); return area/2;}int main (){ return 0;}
0 0
- 自己手打的模板
- 自己手打的Retrofit2+Rxjava 2结合的案例
- 打的
- 测试自己打的war包时刻已正常运行
- 【模板】手读
- 一些手打小模板
- CF被裱了之后很不开心,明明都是我手打的......
- .net 手放模板文件
- C++ BigInt模板手打
- 在我的小芭比上安装yum和apt遇到的翻译手打的好累
- java程序调用exe文件和调用自己打的jar包或其他外部jar包
- vue-cli手脚架模板使用sass
- 自己纯手打算不算原创
- 打造自己称手的代码
- 海贼王 手游 自己搭建自娱自乐
- 自己的KMP模板
- 自己的背包模板
- 盗版不是这样打的
- windows server 2008 搭建VPN
- [Unix]vi 基本操作方法
- 校园招聘面试-操作系统知识总结
- Android开发之Manifest.xml详解
- Ubuntu下firefox更新、中文及同步
- 自己手打的模板
- fork() && fork() || fork()
- LuaXml库的编译
- excel 2007 直方图 条图 黑白 条纹填充
- 面试题-求一个串包含另一个串的最大子串长度的解法
- android系统获取系统相关信息(如Android设备的唯一ID等)(源码)
- [unix]指令大全
- 快速排序
- C#获取电脑的相关信息