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 :). 

InputThe first line contains an integer T, denoting the number of the test cases. 

For each test case, the first line contains an integer n denoting the number of the rotations. Then n lines follows, each containing 3 real numbers x, y and p, which means rotating around point (x, y) counter-clockwisely by a radian of p. 

We promise that the sum of all p's is differed at least 0.1 from the nearest multiplier of 2π. 

T<=100. 1<=n<=10. 0<=x, y<=100. 0<=p<=2π.
OutputFor each test case, print 3 real numbers x, y, p, indicating that the overall rotation is around (x, y) counter-clockwisely by a radian of p. Note that you should print p where 0<=p<2π. 

Your answer will be considered correct if and only if for x, y and p, the absolute error is no larger than 1e-5. 

Sample Input

1
3
0 0 1
1 1 1
2 2 1

Sample Output

1.8088715944 0.1911284056 3.0000000000

划重点!

一个点绕定点旋转的坐标公式:

在平面坐标上,任意点P(x1,y1),绕一个坐标点Q(x2,y2)旋转θ角度后,新的坐标设为(x, y)的计算公式:
  1. x= (x1 - x2)*cos(θ) - (y1 - y2)*sin(θ) + x2 ;
  2. y= (x1 - x2)*sin(θ) + (y1 - y2)*cos(θ) + y2 ;

这道题里最后的旋转角度就是前面所有的旋转角度加起来 因为不管绕哪一个点旋转 整个画面都转过了相同的角度 画面上的每一个点也都转过了相同的角度

先设一个点 对于每一次旋转都对这个点进行旋转 就可以得到最后的时候这个点的坐标

在根据这个点最后的坐标与最开始的坐标 可以反推出旋转中心

emmm感觉自己高中学的几何的公式都忘光了 计算能力也大大下降 解一个复杂一点的方程都解不出了啊天哪好难过

#include <iostream>
#include <algorithm>
#include <cstring> #include <cstdio> #include <cmath> using namespace std;
#define PI 3.1415926
#define EPS 1.0e-5 int t, n;
struct point{
double x, y;
}p[15]; point rot(point& p, point& ding, double theta)
{
point c;
c.x = (p.x - ding.x) * cos(theta) - (p.y - ding.y) * sin(theta) + ding.x;
c.y = (p.x - ding.x) * sin(theta) + (p.y - ding.y) * cos(theta) + ding.y;
return c;
} int main()
{
cin>>t;
while(t--){
scanf("%d",&n);
double anangle = 0.0;
point a, b;
a.x = -1.0; a.y = -20.0;
b.x = -1.0; b.y = -20.0;
for(int i = 0; i < n; i++){
double angle;
scanf("%lf%lf%lf",&p[i].x, &p[i].y, &angle);
a = rot(a, p[i], angle);
anangle += angle;
while(anangle >= 2 * PI){
anangle -= 2 * PI;
} } point ans;
ans.y =(a.x*sin(anangle)+a.y*(1-cos(anangle))-(b.x*cos(anangle)-b.y*sin(anangle))*sin(anangle)-(b.x*sin(anangle)+b.y*cos(anangle))*(1-cos(anangle)))/(2-2*cos(anangle));
ans.x=(a.x*(1-cos(anangle))-a.y*sin(anangle)-(b.x*cos(anangle)-b.y*sin(anangle))*(1-cos(anangle))+(b.x*sin(anangle)+b.y*cos(anangle))*sin(anangle))/(2-2*cos(anangle));
printf("%.6f %.6f %.6f\n", ans.x, ans.y, anangle);
}
return 0; }

hdu4998 Rotate【计算几何】的更多相关文章

  1. hdu4998 Rotate 计算几何

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

  2. HDU 4998 Rotate (计算几何)

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

  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. IOS私有API的使用(转)

    最近在做企业级程序,需要搞设备的udid等信息,但是ios7把udid私有化了,不公开使用.所以研究了一下ios的私有api.   调查了一下文章,发现这方面的文章不多,国内更是不全,高手们都懒得写基 ...

  2. ECharts 3 -- gauge表盘的配置项

    绘制一个简单的表盘图表 在绘图前我们需要为 ECharts 准备一个具备高宽的 DOM 容器. <body> <!-- 为 ECharts 准备一个具备大小(宽高)的 DOM --& ...

  3. Python对象(下)

    前面一篇文章介绍了一些Python对象的基本概念,这篇接着来看看Python对象相关的一些内容. Python对象的比较 Python对象有三个要素:身份,类型和值,所以我们就分别从这三个角度出发看看 ...

  4. 后端判断用户是否关闭浏览器(关闭网站相关的全部tab)

    一)程序步骤 1.js 写一个定时请求后端(php),后端接收到请求到,把当前时间戳写入文件 2.php 阻塞,这里我写的是 30 秒,也就是 sleep(30) 3.获取当前时间和文件里的时间作比较 ...

  5. 利用BurpSuite实现半自动化盲注

    为了方便演示,这里直接使用字符,构造SQL Payload: ?id= and substring(user(),,)='r' 1.使用Burp抓包,发送到Intruder,设置模式和变量 2.设置字 ...

  6. [SublimeText] 之 Packages

    概述 Packages 是指供 Sublime Text 使用的资源文件集合,例如插件.语法高亮.菜单.片断等等.Sublime Text 自身安装了一些 Packages,还有很多用户创建的 Pac ...

  7. [Linux] 修改用户名密码

    1. 普通用户或root用户修改自身登录密码:在终端使用passwd命令. linaro@linaro-ubuntu-desktop:~$ passwd Changing password for l ...

  8. 分析JobInProgress中Map/Reduce任务分配

    1.JobTracker能否决定给当前的TaskTracker节点分配一个Job的具体的哪一个任务? 2.什么是map本地任务? 3.nonRunningMapCache的作用是什么? 4.从Task ...

  9. NUC972配置为支持NFS

    系统平台:virtualbox3.2.10+ubuntu10.10 安装nfs: #sudo apt-get install nfs-kernel-server ubuntu10.10中的已经是最新版 ...

  10. Python进阶 学习笔记(三)

    (涉及内容:定制类) __str__和__repr__ 如果要把一个类的实例变成 str,就需要实现特殊方法__str__(): class Person(object): def __init__( ...