随笔分类 -  计算几何

 
平面点旋转公式
摘要:任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转a角度后的新的坐标设为(x0, y0),有公式:x0= (x - rx0)*cos(a)- (y - ry0)*sin(a) + rx0 ;y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ; 阅读全文
posted @ 2014-10-07 12:23 LegendaryAC 阅读(652) 评论(0) 推荐(0)
HDU 2907
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2907ans=(凸包顶点数-凸包凹面数量)*q-凸包凹面数量*p重点在求一个凸包的凹面数量,极角排序过后,当前点在凸包上,下一个点不在凸包上,则凹面数量加一。这个要求的东西说的十分晦涩,样例不足以解释题目,所以此题... 阅读全文
posted @ 2014-06-22 09:21 LegendaryAC 阅读(176) 评论(0) 推荐(0)
HDU 4720
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4720包含三个点且最小的圆可能是三角形的外接圆或者是以任意两点连成线段的中点为圆心的园,找出最小的即可,然后判断麻瓜到圆心的距离和圆半径之间的关系,注意求外心的前提是三点不共线#include #include #... 阅读全文
posted @ 2014-06-12 20:25 LegendaryAC 阅读(251) 评论(0) 推荐(0)
计算几何基本函数
摘要:#include #include #include #include #include using namespace std ;const double eps = 1e-8;const double PI = acos(-1.0);int sgn(double x){ if(fabs(x... 阅读全文
posted @ 2014-06-12 18:45 LegendaryAC 阅读(245) 评论(0) 推荐(0)
平面最近点对
摘要:HDU 1007 求平面最近点对距离的一半#include #include #include #include #include using namespace std;const double eps = 1e-7;const int MAXN = 100010;const double INF... 阅读全文
posted @ 2014-06-04 21:24 LegendaryAC 阅读(186) 评论(0) 推荐(0)
HDU 1374
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1374已知三点坐标,求三点确定的圆的周长#include #include #include using namespace std ;//由正弦定理 sin90°/d=sinA/a 既d=a/sinA //s=1/2(bcsinA) 既sinA=2s/bc //由海伦公式 s=sqrt(p(p-a)(p-b)(p-c)),p=(a+b+c)/2 #define PI 3.141592653589793int main(){ double x1,y1,x2,y2,x3,y3 ; while(~sc. 阅读全文
posted @ 2013-12-20 14:47 LegendaryAC 阅读(157) 评论(0) 推荐(0)
Graham扫描法
摘要:Graham扫描法求凸包的模板运行之后可以得到存有凸包顶点的栈s和栈顶指针top,n代表总点数这个模板我当时调了很久,主要难点有两个,一个是正确的极角排序,一个是出栈入栈的细节操作,逆时针扫描,这里注意栈内元素不能少于三个,新的点在当前线的顺时针方向就出栈,逆时针入栈这个算法总体来讲还是简单易懂的,... 阅读全文
posted @ 2013-12-10 15:00 LegendaryAC 阅读(1330) 评论(0) 推荐(0)
POJ 1269 Intersecting Lines
摘要:http://poj.org/problem?id=1269两条直线,平行输出NONE,共线输出LINE,相交输出交点坐标p0为交点,求交点坐标的方法是(p1-p0)X(p2-p0)=0 && (p3-p0)X(p4-p0)=0(其中X代表向量叉乘),联立两个方程可求解求得解分母为0时,判断一条直线中的一个点是否在另一条直线上(用上面叉乘的方法),如果是就共线,反之平行View Code #include <iostream>#include <stdio.h>using namespace std ;struct point{ int x,y ;} ; 阅读全文
posted @ 2012-08-03 11:53 LegendaryAC 阅读(192) 评论(0) 推荐(0)
HDU 1140 War on Weather
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1140根据球的切点做简单的判断,一开始找到答案没有跳出循环,各种错。。。View Code #include <iostream>#include <cmath>using namespace std ;const double PI=acos(-1.0) ;//π的表示方法 struct point { double x,y,z ;} ;double dis(point p1,point p2){ return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p 阅读全文
posted @ 2012-06-09 05:49 LegendaryAC 阅读(199) 评论(0) 推荐(0)
判断线段相交
摘要:struct point{ double x,y ;} ;double direction(point p1,point p2,point p){ return (p.x-p1.x)*(p1.y-p2.y)-(p1.x-p2.x)*(p.y-p1.y) ;}bool online(point p1,point p2,point p){ return (p.x=min(p1.x,p2.x) && p.y=min(p1.y,p2.y)) ;}bool intersect(point p1,point p2,point p3,point p4){ double d1=dire... 阅读全文
posted @ 2012-06-09 03:45 LegendaryAC 阅读(152) 评论(0) 推荐(0)
HDU 1086 You can Solve a Geometry Problem too
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1086判断两线段是否相交,用向量搞了View Code #include <iostream>using namespace std ;struct point{ double x,y ;} ;typedef struct L{ point p1,p2 ;}L ;L kk[110] ;double direction(point p1,point p2,point p){ return (p.x-p1.x)*(p1.y-p2.y)-(p1.x-p2.x)*(p.y-p1.y) ;}bool ... 阅读全文
posted @ 2012-06-09 03:41 LegendaryAC 阅读(186) 评论(0) 推荐(0)
HDU 1071 The area
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1071按要求求出面积即可View Code #include <stdio.h>int main(){ int t; double x0,y0,x1,y1,x2,y2; double k,b; double a; double s; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf%lf%lf",&x0,&y0,&x1,&y1,&x2,&y2); k=(y 阅读全文
posted @ 2012-04-16 23:39 LegendaryAC 阅读(193) 评论(0) 推荐(0)
HDU 2540 遮挡判断
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2540只要影子长度大于前面的所有影子长度就okView Code #include <stdio.h>#include <stdlib.h>typedef struct node{ int x,h;}node;node kk[110000];int cmp(const void*a,const void*b){ return (*(node*)a).x-(*(node*)b).x;}int main(){ int n,i; int A,T; while(scanf("%d&q 阅读全文
posted @ 2012-04-14 10:16 LegendaryAC 阅读(227) 评论(0) 推荐(0)
HDU 2108 Shape of HDU
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2108几何计算,判断线段的转向。View Code #include <stdio.h>#include <string.h>#include <math.h>typedef struct point{ int x,y; }point;point kk[100000];int dis(point p1,point p2,point p3){ return (p3.x-p1.x)*(p2.y-p1.y)-(p2.x-p1.x)*(p3.y-p1.y);}int main(){ 阅读全文
posted @ 2012-04-13 23:29 LegendaryAC 阅读(187) 评论(0) 推荐(0)