计算几何
文章平均质量分 65
苏子散人
爱古风,爱代码。
展开
-
判断点是否在多边形内部
1.判断点是否在三角形内部 struct Point{ //点 double x,y; }; struct Vr{ //向量 Point s,e; }; double cross(Vr * v1, Vr * v2) //叉积 { double result=0; result=(v1->e.x-v1->s.x)*(v2->e.y-v2->s.y)-(v2->e.x-v2->s.x原创 2016-08-22 14:17:47 · 340 阅读 · 0 评论 -
poj1113(凸包 卷包裹法)
#include #include #include #include using namespace std; struct Point{ int x,y; }s[1005]; bool cmp(Point a,Point b) //选择最下左的点作为起点 { if(a.y==b.y) return a.x<b.x; else return a.y<b.y; } int cross(原创 2016-08-23 20:37:36 · 343 阅读 · 0 评论 -
hdu2202
由于最大三角形总会由凸包的顶点围成,故要先找到一个凸包,然后枚举凸包的顶点#include #include #include #include using namespace std; #define maxn 50005 const double pi=acos(-1.0); struct Point{ int x,y; }s[maxn]; int st[maxn],top; int原创 2016-10-09 20:04:18 · 308 阅读 · 0 评论 -
输出凸包上的所有点
//从原点开始,按逆时针顺序输出凸包上的每个点 #include #include #include #include using namespace std; struct Point{ int x,y; }s[1005]; bool cmp(Point a,Point b) { if(a.y==b.y) return a.x<b.x; else return a.y<b.原创 2016-10-07 15:55:00 · 549 阅读 · 0 评论 -
poj1113(凸包Graham算法)
//Graham算法 //poj1113此题点坐标为int型 #include #include #include #include using namespace std; #define maxn 1100 const double pi=acos(-1.0); struct Point{ int x,y; }s[maxn]; int st[maxn],top; int cross(原创 2016-10-07 16:28:41 · 422 阅读 · 0 评论