hdu 4613 Points<计算几何>
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4613
题意: 判断一个集合中的点能不能由另一个集合中的点,通过平移,旋转,放缩得到~
思路:先求出集合中的点的凸包,然后枚举每一条边作为起点 ,看原集合中的点能否与要比较的集合中的点一一对应~
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <utility>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;
const int maxn = ;
typedef complex<double> point;
#define X real()
#define Y imag()
point p[maxn],s[maxn], tp[maxn],ts[maxn];
double ang;
int cnttp,cntts;
int n,m,M,T;
const double eps = 1e-;
int sign(double x)
{
if(x>eps)return ;
if( fabs(x)>eps )return -;
return ;
} bool cmp(const point& p1,const point& p2)
{
if( sign(p1.X-p2.X)== ) return ( sign( p1.Y-p2.Y)< );
return sign( p1.X-p2.X)<;
} double det(const point &p1,const point& p2,const point& org)
{
return (p1.X - org.X) * (p2.Y - org.Y) - (p1.Y - org.Y) * (p2.X - org.X);
} void graham(int n,point *p,int& s,point *ch)
{
sort(p,p + n,cmp);
int i,s2;
ch[] = p[];s = ;
for(i = ;i < n;i++) {
while(s > && det(p[i],ch[s - ],ch[s - ])<eps)s--;
ch[s++] = p[i];
}
s2 = s;
for(int i = n - ;i>=;i--) {
while(s>s2 && det(p[i],ch[s - ],ch[s - ])<eps)s--;
ch[s++] = p[i];
}
s--;
} double getAngle(const point& p1,const point& p2)
{
double dot = p1.X * p2.X + p1.Y * p2.Y;
dot /= abs(p1) * abs(p2);
return dot;
} bool check(const point& org,const point& trans)
{
for(int i = ;i<m;i++) {
if(!binary_search(p,p + n,(s[i] - org) * trans + tp[],cmp))return false;
}
return true;
} void gao()
{
scanf("%d",&m);
for(int i = ;i<m;i++) {
scanf("%lf%lf",&s[i].X,&s[i].Y);
}
if(n!=m) {puts("No");return;}
if(n<=){puts("Yes");return;}
graham(m,s,cntts,ts);
double sang;
point org,trans;
point A,B,C;
for(int k=; k<=; ++ k){
for(int i = ;i<m;i++)
s[i].X = -s[i].X;
for(int i = ;i<cntts;i++)
ts[i].X = -ts[i].X;
for(int i = ;i<cntts;i++) {
B = ts[i];
A = ts[(cntts + i - ) % cntts];
C = ts[(i + ) % cntts];
sang = getAngle(A - B,C - B);
if(fabs(sang - ang)<eps) {
org = B;
trans = (tp[] - tp[]) / (A - B);
if(check(org,trans)) {
puts("Yes");
return;
}
trans = (tp[] - tp[]) / (C - B);
if(check(org,trans)) {
puts("Yes");
return;
}
}
}
}
puts("No");
return;
} int main()
{
scanf("%d",&T);
while(T--) {
scanf("%d",&n);
for(int i =;i<n;i++) {
scanf("%lf%lf", &p[i].X, &p[i].Y);
}
if(n>) {
graham(n,p,cnttp,tp);
ang = getAngle(tp[] - tp[],tp[cnttp - ] - tp[]);
}
scanf("%d",&M);
for(int i = ;i<M;i++)
gao();
puts("");
}
return ;
}
hdu 4613 Points<计算几何>的更多相关文章
- HDU 4998 Rotate (计算几何)
HDU 4998 Rotate (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4998 Description Noting is more ...
- hdu 4643 GSM 计算几何 - 点线关系
/* hdu 4643 GSM 计算几何 - 点线关系 N个城市,任意两个城市之间都有沿他们之间直线的铁路 M个基站 问从城市A到城市B需要切换几次基站 当从基站a切换到基站b时,切换的地点就是ab的 ...
- hdu 1700 Points on Cycle(坐标旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...
- HDU 5295 Unstable 计算几何
Unstable 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5295 Description Rasen had lost in labyrint ...
- HDU 1700 Points on Cycle (坐标旋转)
题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...
- HDU 1174 爆头(计算几何)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1174 解题报告:就是用到了三维向量的点积来求点到直线的距离,向量(x1,y1,z1)与(x2,y2,z ...
- hdu 1086(计算几何入门题——计算线段交点个数)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1086 You can Solve a Geometry Problem too Time Limit: 2 ...
- HDU 1700 Points on Cycle (几何 向量旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...
- 2017多校第6场 HDU 6097 Mindis 计算几何,圆的反演
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6097 题意:有一个圆心在原点的圆,给定圆的半径,给定P.Q两点坐标(PO=QO,P.Q不在圆外),取圆 ...
随机推荐
- CCJ PRML Study Note - Chapter 1.6 : Information Theory
Chapter 1.6 : Information Theory Chapter 1.6 : Information Theory Christopher M. Bishop, PRML, C ...
- python其中一个子线程,则退出全部线程,再退出进程
import threading, signal is_exit = False def write_login(self): global is_exit write_log('login rsyn ...
- AX2012全新的批处理方式
AX2009 的批处理操作我们是通过RunBaseBatch framework,我们所要做的事情就是继承RunBaseBatch class,实现里面该实现的方法来执行批处理. AX2012 的批处 ...
- 写给自己的Java程序员学习路线图
恩,做开发的工作已经三年多了,说起来实在是惭愧,自己的知识树还像一棵小草一样,工作中使用到了许多的知识和技术,不过系统性不够.根基不牢.并且不够深入!当然,慢慢的我也更加的清楚,我需要学习一些什么样的 ...
- iOS 如何根据经纬度来定位位置
/** * 初始化一个经纬度结构体 */ CLLocationCoordinate2D center = {[latitudeTF.text floatValue],[longitudeTF.tex ...
- 新安装的ubuntu系统如何设置中文输入法的方案
本文是本人写的第一篇的linux博客,因为很菜,所以就把刚才自己安装中文输入法的过程给大家介绍一下,希望有所帮助. 1.首先,打开命令终端,两种方式,在Dash里面输入terminal然后enter, ...
- Mysql group by 排序问题
类如 有一个 帖子的回复表,posts( id , tid , subject , message , dateline ) , id 为 自动增长字段, tid为该回复的主题帖子的id(外键关联), ...
- C++ STL 简单记录
1,STL提供三种类型的组件:容器.迭代器.算法. 容器: 顺序容器(vector.list.deque.string等)是一系列元素的有序集合: 关联容器(set.multiset.map.mult ...
- C puzzles详解【21-25题】
第二十一题 What is the potential problem with the following C program? #include <stdio.h> int main( ...
- zedboard上移植OPENCV库
zedboard上移植OPENCV库 之前做了很多移植OPENCV库的工作,但是需要包含的各种库,需要交叉编译,X264 ,JPGE ,FFMPGE等等 注意:在<嵌入式系统软硬件协同设计实战指 ...