poj1410】的更多相关文章

题目链接:https://vjudge.net/problem/POJ-1410 题意:判断线段和矩形是否相交. 思路:注意这里的相交包括线段在矩形内,因此先判断线段与矩形的边是否相交,再判断线段的两端点是否在矩形内(因为是矩形,即凸多边形,直接用叉积判断即可,如果是一般的多边形,需要用射线法判断.) AC code: #include<cstdio> #include<algorithm> #include<cmath> #include<cstdlib>…
计算几何的题目, 学cv的要做一下.poj 地址: http://poj.org/problem?id=1410 题意:判断一个直线段,是否与一个矩形有相交点. 解决方案: 判断矩形的每一条边是否与直线段相交, 则归结为判断直线段相交问题,然后判断两条线段是否相交的条件,是看每一条线段的两个点,是否分布在另一条直线的两端. 利用斜率可以求解. // // 1410 #include <iostream> #include <cstdio> #include <cstdlib&…
简单题,注意是实心矩形 #include <iostream> #include <math.h> #include <iomanip> #define eps 1e-8 #define zero(x) (((x)>0?(x):-(x))<eps) #define pi acos(-1.0) struct point { double x, y; }; struct line { point a, b; }; struct point3 { double x…
题目大意:给出一个线段的两端,和矩形两端(不一定是左上和右下),问线段是否与矩形相交(若线段在矩形内也算相交).这题蒸鹅心-- 题目思路:判断所有情况:线段是否在矩形内,线段内一点是否在矩形内,线段是否与四边相交(叉积),线段的两端是否在矩形上,矩形的四点是否在线段上. 要注意的是: 1.如果两条线段的叉积为0,也可能共线但不相交. 2.判断点在线段上的方法:叉积为0,且到两点的距离与线段等长. #include<cstdio> #include<cstdlib> #include…
You are to write a program that has to decide whether a given line segment intersects a given rectangle. An example: line: start point: (4,9) end point: (11,2) rectangle: left-top: (1,5) right-bottom: (7,1)  Figure 1: Line segment does not intersect…
Intersection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12817   Accepted: 3343 Description You are to write a program that has to decide whether a given line segment intersects a given rectangle. An example: line: start point: (4,9)…
题目大意:求线段与实心矩形是否相交. 解题关键:转化为线段与线段相交的判断. #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<iostream> #define eps 1e-8 using namespace std; typedef long long ll; struct Point…
直接用kuangbin的板子,能判不规范,规范和不交 另外线段在矩形内也可以,判断方式是比较线段的端点和矩形四个角 #include <cstdio> #include <cmath> #include <algorithm> #include <iostream> using namespace std; ; ; )?:-;} struct Point{ double x,y; Point(,):x(_x),y(_y){} bool operator ==…
1.poj2318 TOYS 传送:http://poj.org/problem?id=2318 题意:有m个点落在n+1个区域内.问落在每个区域的个数. 分析:二分查找落在哪个区域内.叉积判断点与线段的位置. #include<iostream> #include<cstring> #include<algorithm> using namespace std; ; struct point{ int x,y; point(){ } point(int _x,int…
图论 图论解题报告索引 DFS poj1321 - 棋盘问题 poj1416 - Shredding Company poj2676 - Sudoku poj2488 - A Knight's Journey poj1724 - ROADS(邻接表+DFS) BFS poj3278 - Catch That Cow(空间BFS) poj2251 - Dungeon Master(空间BFS) poj3414 - Pots poj1915 - Knight Moves poj3126 - Prim…