几何
zzuzxy
牛顿说:“我不知道世人怎样看我,但我自己以为我不过像一个在海边玩耍的孩子,不时为发现比寻常更为美丽的一块卵石或一片贝壳而沾沾自喜,至于展现在我面前的浩翰的真理海洋,却全然没有发现。”
展开
-
经纬度转换为三维坐标
// 经纬度转换为球坐标double torad(double deg){ return deg/180*acos(-1);}void get_coordinate(double R,double lat,double lng,double &x,double &y,double z){ lat = torad(lat); lng = torad(lng);原创 2018-02-01 11:14:37 · 6135 阅读 · 1 评论 -
平面几何常用模板
平面几何常用模板定义点的类struct Point{ double x,y; Point(double x,double y):x(x),y(y){}};定义向量的类typedef Point Vector;定义向量的基本运算Vector operator + (Vector A,Vector B){ return ...原创 2017-12-10 16:39:55 · 306 阅读 · 0 评论 -
二维几何常用模版(圆)
//用到的一些函数和类 看这里定义圆的类struct Circle{ Point c; double r; Circle(Point c ,double r):c(c),r(r){} Point point(double a) { return Point (c.x+cos(a)*r,c.y+sin(a)*r); }};定义直线的类...原创 2018-01-01 16:51:40 · 337 阅读 · 0 评论 -
凸包 模版
//计算凸包,输入点数组p,个数为p,输出点数组为ch。函数返回凸包顶点数//输入不能有重复节点//如果精度要求搞需要用dcmp判断//如果不希望在边上右点,需要将 <= 改为 < int ConvexHull(Point *p,int n ,Point *ch){ sort(p,p+n); int m = 0; for(int i = 0;i < n; ++i)原创 2018-02-05 23:38:42 · 141 阅读 · 0 评论 -
算法竞赛入门经典训练指南第四章几何专题答案
紫书第四章几何部分部分答案在看完书上的解析感觉有些地方解释的太过简单,对于我这等智商的人来说需要好好斟酌,于是记下,希望有用 1. 2D Geometry 110 in 1! UVA - 12304 我的代码 2. 点集划分 — The Great Divid...原创 2018-01-31 21:46:08 · 187 阅读 · 0 评论 -
判断点是否在多边形内
typedef vector<Point> Polygon;int isPointInPolygon(Point p,Polygon poly){ int n = poly.size(); int wn = 0; for(int i = 0;i < n; ++i) { if(Onsegment(p,poly[i],poly[(...原创 2018-02-06 12:24:00 · 168 阅读 · 0 评论 -
Viva Confetti UVALive - 2572
Viva Confetti UVALive - 2572**离散化的思想,将每一个圆都分成一个个小圆弧const int maxn = 100+10;Point center[maxn];double radius[maxn];int n;bool vis[maxn];int judge(Point p){ for(int i = n-1; i >= 0; --i原创 2018-02-06 22:18:22 · 178 阅读 · 0 评论 -
Squares UVALive - 4728
Squares UVALive - 4728题意 求多边形的直径(及距离最远的两点的距离) 1. 首先求凸包,因为所求的最远的两个点肯定是凸包上的点 2. 取最下面点Pi" role="presentation">PiPiP_i和最上面的点Pj" role="presentation">PjPjP_j为对踵点(对踵点,以这一点做两平行直线可以包含整个凸包,距离最远的两个点必为对踵点)原创 2018-02-06 22:16:21 · 177 阅读 · 0 评论