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 计算几何的更多相关文章

  1. HDU 4998 Rotate (计算几何)

    HDU 4998 Rotate (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4998 Description Noting is more ...

  2. hdu4998 Rotate【计算几何】

    Noting is more interesting than rotation!  Your little sister likes to rotate things. To put it easi ...

  3. 【几何模板加点小思路】hdu-4998 Rotate

    用几何模板敲的,也有直接公式推的,追求短代码的可以点右上角小红了...... 题意就是想想一个物体分别做绕某一点(给出坐标)旋转p度(给出角度)后,其位置等价于绕哪一点旋转多少度,输出该等价点及其等价 ...

  4. sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

  5. 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 ...

  6. Rotate

    hdu4998:http://acm.hdu.edu.cn/showproblem.php?pid=4998 题意:给你n个点,以及绕每个点旋转的弧度.然后,问你经过这n次旋转,平面中的点总的效果是相 ...

  7. UVA12304 2D Geometry 110 in 1! 计算几何

    计算几何: 堆几何模版就能够了. . .. Description Problem E 2D Geometry 110 in 1! This is a collection of 110 (in bi ...

  8. 计算几何总结(Part 1~2)

    Preface 对于一个初三连三角函数都不会的蒟蒻来说计算几何简直就是噩梦. 反正都是要学的也TM没办法,那就慢慢一点点学起吧. 计算几何要有正确的板子,不然那种几百行CODE的题写死你. 本蒟蒻的学 ...

  9. UVA 12304 - 2D Geometry 110 in 1! - [平面几何基础题大集合][计算几何模板]

    题目链接:https://cn.vjudge.net/problem/UVA-12304 题意: 作为题目大合集,有以下一些要求: ①给出三角形三个点,求三角形外接圆,求外接圆的圆心和半径. ②给出三 ...

随机推荐

  1. laravel 连表查询数据库

    $this->model ->select($field) ->leftJoin('b', 'b.cid', '=', 'a.id') ->orderBy("a.ad ...

  2. nginx+tomcat集群

    参考: 简单:http://blog.csdn.net/wang379275614/article/details/47778201 详细:http://www.jb51.net/article/77 ...

  3. 写一个xml文件到磁盘的方法

    /** * 往磁盘上写一个xml文件 * * <?xml version="1.0" encoding="UTF-8" standalone=" ...

  4. MATLAB图片折腾1

    MATLAB 把文件夹里图片转成mat文件 pt='/Users/haoyuguo/Desktop/sync1/'; ext='*.jpg'; dis=dir([pt ext]); nms={dis. ...

  5. [Leetcode 392]判断子序列 Is Subsequence

    [思路] 判断s是否为t的子串,所以length(s)<=length(t).于是两个指针,一次循环. 将s.t转换为数组p1.p2. i为过程中s的匹配长度. i=0空串,单独讨论返回true ...

  6. Find the Missing Number II

    Giving a string with number from 1-n in random order, but miss 1 number.Find that number. Notice n & ...

  7. error MSB8008: 指定的平台工具集(V120)未安装或无效。

    打开项目属性->配置属性->右面,平台工作集,选为v10 如下图

  8. DevExpress WinForms v18.2新版亮点(四)

    行业领先的.NET界面控件2018年第二次重大更新——DevExpress v18.2日前正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress WinForms v1 ...

  9. display_errors","On");和error_reporting 区别和联系

    ini_set("display_errors","On");和error_reporting(E_ALL);   在用php做网站开发的时候 , 为防止用户看 ...

  10. Ubuntu16.04下通过tar.gz包安装MySQL5.5.52

    1.下载  tar.gz包 : https://dev.mysql.com/downloads/mysql/ 2. // 安装依赖 sudo apt-get install libaio-dev // ...