hdu4998 Rotate 计算几何
Noting is more interesting than rotation!
Your little sister likes to rotate things. To put it easier to analyze, your sister makes n rotations. In the i-th time, she makes everything in the plane rotate counter-clockwisely around a point ai by a radian of pi.
Now she promises that the total effect of her rotations is a single rotation around a point A by radian P (this means the sum of pi is not a multiplier of 2π).
Of course, you should be able to figure out what is A and P :).
计算几何
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const double eps=1e-;
const double pi=acos(-1.0); int sgn(double x){
if(fabs(x)<eps) return ;
if(x<) return -;
else return ;
} struct Point{
double x,y;
Point(){}
Point(double _x,double _y){
x=_x;
y=_y;
}
Point operator -(const Point &b)const{
return Point(x-b.x,y-b.y);
}
double operator ^(const Point &b)const{
return x*b.y-y*b.x;
}
double operator *(const Point &b)const{
return x*b.x+y*b.y;
}
Point operator +(const Point &b)const{
return Point(x+b.x,y+b.y);
}
Point operator *(const double &k)const{
return Point(x*k,y*k);
}
Point operator /(const double &k)const{
return Point(x/k,y/k);
}
Point rotate(Point p,double angle){
Point v=(*this)-p;
double c=cos(angle),s=sin(angle);
return Point(p.x+v.x*c-v.y*s,p.y+v.x*s+v.y*c);
}
double len2(){
return x*x+y*y;
}
}; struct Line{
Point s,e;
Line(){}
Line(Point _s,Point _e){
s=_s;
e=_e;
}
Point crosspoint(Line v){
double a1=(v.e-v.s)^(s-v.s);
double a2=(v.e-v.s)^(e-v.s);
return Point((s.x*a2-e.x*a1)/(a2-a1),(s.y*a2-e.y*a1)/(a2-a1));
}
Point lineprog(Point p){
return s+( ((e-s)*((e-s)*(p-s)))/((e-s).len2()) );
}
}; void solve(){
int n,i;
double x,y,p,nx,ny,np;
Point a,b,c,d,e,f,g;
Line l1,l2,l3,l4;
scanf("%d",&n);
scanf("%lf%lf%lf",&nx,&ny,&np);
for(i=;i<=n;i++){
scanf("%lf%lf%lf",&x,&y,&p);
a=Point(nx,ny);b=Point(x,y);
d=a.rotate(b,p);c=b.rotate(a,-np);
l1=Line(c,b);l2=Line(a,d);
e=l1.lineprog(a);f=l2.lineprog(b);
l3=Line(a,e);l4=Line(b,f);
g=l3.crosspoint(l4);
nx=g.x;ny=g.y;
np=np+p;
if(np>*pi) np-=*pi;
}
printf("%lf %lf %lf\n",nx,ny,np);
} int main(){
int t;
scanf("%d",&t);
while(t)solve();
return ;
}
hdu4998 Rotate 计算几何的更多相关文章
- HDU 4998 Rotate (计算几何)
HDU 4998 Rotate (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4998 Description Noting is more ...
- hdu4998 Rotate【计算几何】
Noting is more interesting than rotation! Your little sister likes to rotate things. To put it easi ...
- 【几何模板加点小思路】hdu-4998 Rotate
用几何模板敲的,也有直接公式推的,追求短代码的可以点右上角小红了...... 题意就是想想一个物体分别做绕某一点(给出坐标)旋转p度(给出角度)后,其位置等价于绕哪一点旋转多少度,输出该等价点及其等价 ...
- sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)
Rescue The Princess Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Several days ago, a b ...
- HDU 4063 Aircraft(计算几何)(The 36th ACM/ICPC Asia Regional Fuzhou Site —— Online Contest)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4063 Description You are playing a flying game. In th ...
- Rotate
hdu4998:http://acm.hdu.edu.cn/showproblem.php?pid=4998 题意:给你n个点,以及绕每个点旋转的弧度.然后,问你经过这n次旋转,平面中的点总的效果是相 ...
- UVA12304 2D Geometry 110 in 1! 计算几何
计算几何: 堆几何模版就能够了. . .. Description Problem E 2D Geometry 110 in 1! This is a collection of 110 (in bi ...
- 计算几何总结(Part 1~2)
Preface 对于一个初三连三角函数都不会的蒟蒻来说计算几何简直就是噩梦. 反正都是要学的也TM没办法,那就慢慢一点点学起吧. 计算几何要有正确的板子,不然那种几百行CODE的题写死你. 本蒟蒻的学 ...
- UVA 12304 - 2D Geometry 110 in 1! - [平面几何基础题大集合][计算几何模板]
题目链接:https://cn.vjudge.net/problem/UVA-12304 题意: 作为题目大合集,有以下一些要求: ①给出三角形三个点,求三角形外接圆,求外接圆的圆心和半径. ②给出三 ...
随机推荐
- css3 居中(推荐弹性盒模型方式)
参考 http://www.zhihu.com/question/20774514 http://caibaojian.com/demo/flexbox/align-items.html 例子:ht ...
- 搭建Hadoop2.7.1的分布式集群
Hadoop 2.7.1 (2015-7-6更新),hadoop的环境配置不是特别的复杂,但是确实有很多细节需要注意,不然会造成许多配置错误的情况.尽量保证一次配置正确防止反复修改. 网上教程有很多关 ...
- svn服务器搭建及使用(二)
上一篇介绍了VisualSVN Server和TortoiseSVN的下载,安装,汉化.这篇介绍一下如何使用VisualSVN Server建立版本库,以及TortoiseSVN的使用. 首先打开Vi ...
- webView 的种种
1.关于UI 我们在设置webview的时候,有时候会发现在加载的过程中会出现一个黑色的条条,在加载完成的时候有得时候继续存在,有得时候消失不见. 这个黑边是由于webView.scrollview向 ...
- hdu-2063-过山车(匈牙利算法)
过山车 Problem Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找 ...
- eclipse项目环境搭建(做了好多遍,老是忘记,以此文帮助记忆)
今天把eclipse的环境搭建好(不能用myeclipse好忧伤). 要求: 1.在svn上管理项目,要下载svn插件. 2.是web所以要用到tomcat插件. 3.将项目运行起来. 流程: ecl ...
- 2.1FTP的简单传输
第一个简单的FTP传输实例 from ftplib import FTP nonpassive = False filename = 'new_1.py' dirname = '.' sitename ...
- mvc项目中实现备份数据库(sqlserver2005)
功能要求:mvc项目,实现数据库备份(bak文件) 实现步骤:<a id="backupDB" href="javascript:" >数据库备份& ...
- Arduino 串口输出LM35温度
#include "stdlib.h" float temp = 0.0; float maxtemp = 0.0; float mintemp =100.0; // the se ...
- dos命令:网络相关命令
网络相关命令 一.Arp命令 1.介绍 显示和修改地址解析协议(ARP)使用的“IP 到物理”地址转换表. 2.语法 ARP -s inet_addr eth_addr [if_addr] ARP ...