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. go的精选类库

    https://github.com/avelino/awesome-go https://gitee.com/snail/proxy

  2. linux ss命令使用详解

    ss是Socket Statistics的缩写.顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容.但ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信 ...

  3. Present ViewController Modally (转)

    一.主要用途 弹出模态ViewController是IOS变成中很有用的一个技术,UIKit提供的一些专门用于模态显示的ViewController,如UIImagePickerController等 ...

  4. 手机APP支付--整合支付宝支付控件

    长话短说,本文根据支付宝官方说明文档,简单总结下,并且说明下开发过程碰到的问题以及该如何解决. 整合步骤: 1 登录商家服务网站,下载开发包,地址:https://b.alipay.com/order ...

  5. 01-虚拟软件vmware安装

    什么是虚拟软件: 虚拟原件是一个可以使你在一台机器上同时运行二个或更多Windows.LINUX等系统.它可以模拟一个标准PC环境.这个环境和真实的计算机一样,都有芯片组.CPU.内存.显卡.声卡.网 ...

  6. ios开发之--仿(微信)自定义表情键盘

    先附上demo:https://github.com/hgl753951/CusEmoji.git 效果图如下:

  7. PostgreSQL的表空间

    1. 表空间的概念 PostgreSQL中的表空间允许在文件系统中定义用来存放表示数据库对象的文件的位置.在PostgreSQL中表空间实际上就是给表指定一个存储目录. 2. 表空间的作用 官方解释 ...

  8. HttpClient(一)-- HelloWorld

    一.简介 HttpClient 是Apache Jakarta Common 下的子项目,可以用来提供高效的.最新的.功能丰富的支持 HTTP 协议的客户端编程工具包,并且它支持 HTTP 协议最新的 ...

  9. 使用 urllib 解析 URL 链接

    urllib 库还提供了 parse 模块,它定义了处理 URL 的标准接口,例如实现 URL 各部分的抽取.合并以及链接转换,常用的方法如下: In []: from urllib.parse im ...

  10. pip导出安装包及批量安装

    python导出安装包及版本 pip freeze > requirements.txt 批量安装pip install -r requirements.txt