hdu 2108(判断多边形是凸的,还是凹的)
摘要:/** 利用叉乘判断多边形是凸的,还是凹的* auther:Try86 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;struct point { int x; int y;}A, B, C, tA, tB;int crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);}int main() { int n; while (scanf
阅读全文
posted @
2012-04-22 21:37
Try86
阅读(406)
推荐(0)
hdu 1756(判断点是否在多边形内)
摘要:/** 题意:判断点在多边形内* 判点在任意多边形内,顶点按顺时针或逆时针给出*/#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 100;const int offset = 1000; //offset为多边形坐标上限const double eps = 1e-8;struct point { double x; double y;}p[N], p1, p2;bool isZero(do
阅读全文
posted @
2012-04-22 20:44
Try86
阅读(1915)
推荐(0)
hrbust OJ13哥的机器人(利用叉乘判断拐向)
摘要:View Code /** 利用叉乘判断拐向 * auther:Try86*/#include <cstdio>#include <iostream>using namespace std;char str[1000];struct point { int x; int y;}A, B, C;int crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);}int main() { int n; while (scanf("%d",
阅读全文
posted @
2012-04-22 11:39
Try86
阅读(186)
推荐(0)
hrbustOJ 围困(判断点是否在三角形内)
摘要:View Code /** 题目要求:判断点是否在三角形内* 可利用叉乘判断拐向来解决 * auther:Try86*/#include <cstdio>#include <iostream>using namespace std;struct point { int x; int y;}A, B, C, D;int crossProd(point A, point B, point C) { return (B.x-A.x)*(C.y-A.y) - (B.y-A.y)*(C.x-A.x);}bool inTrangle() { if (crossProd(D, ...
阅读全文
posted @
2012-04-22 10:54
Try86
阅读(147)
推荐(0)
hrbustOJ 受到攻击(判断点是否在凸多边形内包括边界)
摘要:View Code /** 题目要求:判断点是否在凸多边形内 * 方法:利用叉乘判断拐向来求解 * auther:Try86 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 100;struct point { double x; double y;}p[N], doTa;double crossProd(point A, point B, point C){ return (B.x-A.x)*(C.y-A.y) - (B.y-
阅读全文
posted @
2012-04-22 10:36
Try86
阅读(197)
推荐(0)
hdu 2671(点关于直线对称问题)
摘要:View Code /** 题目所求:在直线上找一点P,使其与其它(A,B)两点组成的距离最短 * 点A跟点B与直线的位置情况四种:* 1.两点在直线的同侧(两点都不在直线上) * 2.两点在直线的异侧(两点都不在直线上) * 3.其中一点在直线上* 4.两点都在直线上* auther:Try86 */#include <cmath>#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;struct point {//点结构 double x; doub
阅读全文
posted @
2012-04-22 10:03
Try86
阅读(197)
推荐(0)
hdu 1086(判断线段相交)
摘要:View Code /** 题目要求:求一组线段的总的交点数* 判断两线段相交:1快速排斥,2跨立实验 */#include <cstdio>#include <cstdlib>#include <iostream>using namespace std;const int N = 100;struct point {//点结构 double x; double y;};struct segment {//线段结构 point s; point e;}seg[N];double crossProd(point A, point B, point C) { .
阅读全文
posted @
2012-04-22 08:36
Try86
阅读(194)
推荐(0)
hdu 1115(求密度均匀的多边形的重心)
摘要:View Code /*摘自:KIDxの博客 求多边形重心的题目大致有这么几种: 1、质量集中在顶点上 n个顶点坐标为(xi,yi),质量为mi,则重心 X = ∑( xi×mi ) / ∑mi Y = ∑( yi×mi ) / ∑mi 特殊地,若每个点的质量相同,则 X = ∑xi / n Y = ∑yi / n 2、质量分布均匀 特殊地,质量均匀的三角形重心: X = ( x0 + x1 + x2 ) / 3 Y = ( y0 + y1 + y2 ) / 3 3、质量分布不均匀 只能用函数多重积分来算,不太会 这题的做法: 将n边形分成多个三...
阅读全文
posted @
2012-04-21 22:14
Try86
阅读(637)
推荐(1)
hdu 2036(计算多边形的面积)
摘要:View Code /** 题目要求:计算多边形面积* 方法:把n多边形分割成n-2个三角形,分别求和,然后相加* 注意:分割的所有三角形有一个公共的顶点,这里选择0点位公共点 * 注:题中给出的点的顺序为逆时针 * auther:Try86 */ /** 叉乘的性质:设两向量P和Q * 1.P ×Q > 0 则Q在P的逆时针方向 * 2.P ×Q < 0 则Q在P的顺时针方向* 3.P ×Q = 0 则Q和P共线,方向可能相同也可能不相同 *//** 实现一 */#include <cmath>#include <cstdio>
阅读全文
posted @
2012-04-21 21:26
Try86
阅读(156)
推荐(0)
hdu 1859(计算几何)
摘要:/* Name: 计算几何 Author: Try_86 Date: 11/04/12 18:07 Description: 求x,y的最大最小值即可 */#include <cstdio>#include <climits>#include <iostream>using namespace std;int main() { int x, y, minx, miny, maxx, maxy; while (scanf("%d%d", &x, &y), x!=0 || y!=0){ minx = INT_MAX; miny
阅读全文
posted @
2012-04-11 18:10
Try86
阅读(187)
推荐(0)