随笔分类 -  计算几何

我爱数学
摘要:枚举两个多边形的两个点组成的直线,判断能与几个多边形相交因为最佳的直线肯定可以经过某两个点(可以平移到顶点处),所以暴力枚举两个点就好了View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <algorithm> 5 using namespace std; 6 const double eps = 1e-8; 7 const double pi = acos(-1.0); 8 struct Point { 9 double x, y; 1 阅读全文
posted @ 2011-11-06 22:49 Because Of You 阅读(377) 评论(0) 推荐(0)
摘要:验一下模板。。。。#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const double eps = 1e-8;const double pi = acos(-1.0);struct Point { double x, y; Point operator - (const Point& t) const { Point tmp; tmp.x = x - t.x; tmp.y = y - t.y; ... 阅读全文
posted @ 2011-10-20 16:09 Because Of You 阅读(420) 评论(0) 推荐(0)
摘要:有点恶心,线段完全在长方形内,也算相交。。。。还好热心网友发了数据 http://hi.baidu.com/lewutian/blog/item/9a8a38ece87cd52c62d09fb5.html#include<stdio.h>#include<math.h>const double eps = 1e-8;struct Point { double x, y; Point operator - (const Point& t) const { Point tmp; tmp.x = x - t.x; tmp.y = y - t.y;... 阅读全文
posted @ 2011-10-20 14:30 Because Of You 阅读(403) 评论(0) 推荐(0)
摘要:输出的时候要注意#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<stdlib.h>using namespace std;const double eps = 1e-8;struct point { double x,y;}p[20010];int top;bool cmpxy(point a,point b){ if(fabs(a.y-b.y)>eps) return a.y<b.y; return a.x< 阅读全文
posted @ 2011-10-18 19:19 Because Of You 阅读(284) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>struct point{ int x,y;}p[1000];int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int onedge(int n,point *p)//多边形边上的网格点数{ int i,ret=0; for(i=0;i<n;i++) ret+=gcd(abs(p[i].x-p[(i+1)%n].x),abs(p[i]. 阅读全文
posted @ 2011-10-18 12:22 Because Of You 阅读(169) 评论(0) 推荐(0)
摘要:判断重心在每条凸包边上的的垂足是否在凸包边上,计算几何一般思路很清晰,就是实现起来有点烦,这里错一点,那里错一点,所以,以后决定要把几何题放最后做了第一种方法:求出垂足再判断#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;const double eps = 1e-8;struct point { double x,y; point operator - (const point& t) const { po 阅读全文
posted @ 2011-10-18 11:07 Because Of You 阅读(441) 评论(0) 推荐(0)
摘要:直接用模板的,但浙大费马点的模板貌似不太好用啊。。。就自己写了注意题目给出的是三边长,要先把这三边转换成三个顶点坐标。另外,三角形中有一个角的角度大于120度时,距离之和就为三角形较短两边之和View Code #include<stdio.h>#include<math.h>#include<string.h>#include<algorithm>using namespace std;const double pi=acos(-1.0);struct point{double x,y;};struct line{point a,b;};dou 阅读全文
posted @ 2011-10-12 16:41 Because Of You 阅读(458) 评论(0) 推荐(0)
摘要:View Code 把向量旋转到一个圆内,三点确定一个圆#include<stdio.h>#include<math.h>#include<stdlib.h>const double pi=acos(-1.0);const double eps = 1e-8;struct Line { double a, b, c;};struct Point { double x, y; Point operator - (const Point& t) const { Point tmp; tmp.x = x - t.x; tmp.y = y -... 阅读全文
posted @ 2011-10-09 18:18 Because Of You 阅读(340) 评论(0) 推荐(0)
摘要:计算几何好题View Code #include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>#include<algorithm>using namespace std;const double eps =1e-9;const double PI = acos(-1);struct point { double x,y;}a[1000];double b[2000];__int64 C(int a,int b){ int i; __int64 aa=a,bb 阅读全文
posted @ 2011-10-06 21:51 Because Of You 阅读(259) 评论(0) 推荐(0)
摘要:做了一个晚上的题目,晕了View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;const double eps=1e-9;#define zero(x) (((x)>0? (x):-(x))<eps)struct point{ double x,y;}a[1010];int n,s[1010];int top;int cmp(point a,point b){ if(a.y==b.y) re 阅读全文
posted @ 2011-10-05 21:24 Because Of You 阅读(322) 评论(0) 推荐(0)
摘要:还是太粗心了阿,求直线上的点到两点间距离和的最小值搞了好久阿,A点和B点有可能在直线的同侧也可能在异侧View Code #include<stdio.h>#include<math.h>const double eps = 1e-9;struct point{ double x,y;}A,B,C,A1,node;double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}double cross(point a,point b,point c){ return ( 阅读全文
posted @ 2011-10-05 16:52 Because Of You 阅读(323) 评论(0) 推荐(0)
摘要:仔细想想后发现其实只要求出各个面面积的大小即可。easy~ 阅读全文
posted @ 2011-10-01 10:40 Because Of You 阅读(149) 评论(0) 推荐(0)
摘要:题目任意给出四个点,求出到这四个点的距离之和最小的点到这四个点的距离若四边形为凸的,费马点为对角线交点,否则为凹的那点证明很简单,把要证明的那点与其他顶点连起来,再任取一点,证明这点到四个顶点的距离比原来那点长即可View Code #include<stdio.h>#include<math.h>#include<string.h>const double esp=1e-8;struct point{ double x,y;}a[10];struct line { double a,b,c;};double min(double a,double b){ 阅读全文
posted @ 2011-09-24 20:35 Because Of You 阅读(492) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<math.h>#include<string.h>#include<algorithm>using namespace std;#define N 1001const double pi=acos(-1.0);struct point { int x,y;}node[N];int s[N];int top;int cmp(point a,point b){ if(a.y==b.y) return a.x<b.x; return a.y<b.y;}double ch 阅读全文
posted @ 2011-09-17 21:29 Because Of You 阅读(213) 评论(0) 推荐(0)