Problem Description

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

Input

The 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π.

Output

For
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



图,如果整个屏幕按照A点逆时针旋转a度,就会如图虚线的坐标。根据旋转,可以得到任意一个点旋转后的坐标。还有一点就是旋转最后的综合角度就是直接旋转
角度之和。然后最后得到的O'点,可以通过综合角度a,算出综合旋转中心A。这个旋转中心可以通过先将O‘沿OO’方向移位,使得,OA=OO‘,然后将
O’按照O逆时针旋转到A,求得,旋转角度是pi/2-a/2。

代码:

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <string>
#define inf 0x3fffffff
#define esp 1e-10
using namespace std;
void Rotate(double &x0, double &y0, double x, double y, double a)
{
double xx, yy;
xx = x0*cos(a) - y0*sin(a) + x*( - cos(a)) + y*sin(a);
yy = x0*sin(a) + y0*cos(a) + y*( - cos(a)) - x*sin(a);
x0 = xx;
y0 = yy;
}
int main()
{
//freopen ("test.txt", "r", stdin);
int T;
scanf ("%d", &T);
for (int times = ; times < T; ++times)
{
double x0 = , y0 = , x, y, a, p = , ans, pi = 3.14159265358979323846;
int n;
scanf ("%d", &n);
for (int i = ; i < n; ++i)
{
scanf ("%lf%lf%lf", &x, &y, &a);
p += a;
Rotate(x0, y0, x, y, a);
}
while (p > *pi)
{
p -= *pi;
}
ans = p;
double k = /sin(p/2.0)/2.0;
x0 = x0 * k;
y0 = y0 * k;
p = pi/2.0 - p/2.0;
Rotate(x0, y0, , , p);
printf ("%f %f %f\n", x0, y0, ans);
}
return ;
}

ACM学习历程—Rotate(HDU 2014 Anshan网赛)(几何)的更多相关文章

  1. ACM学习历程—广东工业大学2016校赛决赛-网络赛F 我是好人4(数论)

    题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=5 这个题目一看就是一道数论题,应该考虑使用容斥原理,这里对lcm进行容斥. ...

  2. ACM学习历程—广东工业大学2016校赛决赛-网络赛E 积木积水(最值问题 || 动态规划)

    题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=4 这个题目自然会考虑到去讨论最长或者最短的板子. 笔上大概模拟一下的话,就 ...

  3. ACM学习历程—广东工业大学2016校赛决赛-网络赛D 二叉树的中序遍历(数据结构)

    题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=3 这算是一个胡搞类型的题目.当然肯定是有其数据结构支撑的. 唯一的限制就是 ...

  4. ACM学习历程—广东工业大学2016校赛决赛-网络赛C wintermelon的魔界寻路之旅(最短路 && 递推)

    题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=2 题目由于要找对称的路径,那么狠明显可以把右下角的每一块加到左上角对应的每 ...

  5. ACM学习历程—Hihocoder编程之美测试赛B题 大神与三位小伙伴(组合数学 )

    时间限制:2000ms 单点时限:1000ms 内存限制:256MB 描述 给你一个m x n (1 <= m, n <= 100)的矩阵A (0<=aij<=10000),要 ...

  6. ACM学习历程——HDU 5014 Number Sequence (贪心)(2014西安网赛)

    Description There is a special number sequence which has n+1 integers. For each number in sequence, ...

  7. ACM学习历程—HDU 5459 Jesus Is Here(递推)(2015沈阳网赛1010题)

    Sample Input 9 5 6 7 8 113 1205 199312 199401 201314 Sample Output Case #1: 5 Case #2: 16 Case #3: 8 ...

  8. ACM学习历程—HDU 5451 Best Solver(Fibonacci数列 && 快速幂)(2015沈阳网赛1002题)

    Problem Description The so-called best problem solver can easily solve this problem, with his/her ch ...

  9. ACM学习历程—HDU 5443 The Water Problem(RMQ)(2015长春网赛1007题)

    Problem Description In Land waterless, water is a very limited resource. People always fight for the ...

随机推荐

  1. 识别不了socket未知的名称或服务

    个人博客地址:https://blog.sharedata.info/ socket 链接导致java.net.UnknownHostException: R1-T1-N6: R1-T1-N6: 未知 ...

  2. SQLServer2008 统计表占用空间

    1.查看一张表占用的空间大小 EXEC sp_spaceused '表' 1.查看一个数据库中所有表占用空间大小 EXEC sp_MSforeachtable 'sp_spaceused " ...

  3. ubuntu14.04 desktop 32-bit kvm装windows xp

    经过这几天来的折腾,总算是在ubuntu14.04用kvm装上了xp, 看不少的的贴,也绕了不少的圈,总的来说,非常感谢CSDN上的"上善若水75",看着他写的一个分类" ...

  4. org.apache.poi3.1.7 Excle并发批量导入导出

    org.apache.poi3.1.7 升级,需要修改设置方式: 1.org.apache.poi3.1.4 的设置单元格: XSSFCellStyle cellStyle = wb.createCe ...

  5. Django之stark组件的使用和总结

    Stark组件的使用 组件的字段 list_display=[] 需要显示的字段 list_display_links=[] #需要链接编辑字段 Stark_Model_Form=[] #设置Mode ...

  6. js:深入函数的定义

    函数定义方式: 1.function fun1(){alert("fun1");}  //函数就是一个很特殊的对象.是一个Function的实例.事实上在内存中存储的操作是通过一个 ...

  7. dva+antd写的一个react例子

    github地址 https://github.com/shenggen1987/dva-cli-demo 效果图片

  8. 自编码器(autoencoder)

    今天我们会来聊聊用神经网络如何进行非监督形式的学习. 也就是 autoencoder, 自编码. 压缩与解压 有一个神经网络, 它在做的事情是 接收一张图片, 然后 给它打码, 最后 再从打码后的图片 ...

  9. ubuntu sudo-update出错Encountered a section with no Package: header

    Reading package lists... Error! E: Encountered a section with no Package: header E: Problem with Mer ...

  10. Android Media应用开发

    Java层API : AudioRecord 采集音频(PCM格式)AudioTrack 播放音频 Camera 用来采集摄像头的数据Surface / SurfaceView / GLSurface ...