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. c# 当前不会命中断点 未载入该文档

    C#编码时.有时会遇到标题所说的问题,就是说这个文件和方法明明存在,可总是提示找不到方法.解决方法例如以下: 1.清理全部项目(或相关项目)生成 2.又一次加入全部项目(或相关项目)间的互相引用 3. ...

  2. HDU-4031-Attack(树状数组)

    Problem Description Today is the 10th Annual of "September 11 attacks", the Al Qaeda is ab ...

  3. apple-touch-icon-precomposed 和 apple-touch-icon属性区别

    苹果safari浏览器当中apple-touch-icon-precomposed 和 apple-touch-icon属性是有区别的,之前在网上查了下相关的资料和苹果的开发文档手册,对这两中属性区别 ...

  4. Spring MVC中的模型数据处理

    一.综述 Spring MVC 提供了以下途径来输出模型数据: 1.ModelAndView 当处理方法返回值类型为 ModelAndView时, 方法体即可通过该对象添加模型数据到请求域. 2.Ma ...

  5. 智能家居DIY-空气质量检测篇-获取温度和湿度篇

    目录 智能家居DIY-空气质量检测篇-获取空气污染指数 前言 话说楼主终于升级当爸了,宝宝现在5个月了,宝宝出生的时候是冬天,正是魔都空气污染严重的时候,当时就想搞个自动开启空气净化器,由于种种原因一 ...

  6. ros下单目相机校正

    1. 安装对应的驱动与程序包. 图像对应包   http://wiki.ros.org/camera_calibration          在gitbub下载image_pipeline :    ...

  7. js格式化货币金额

    /* 格式化金额, s : 金额 n : 保留位数 */ function formatMoney(s, n) { n = n > 0 && n <= 20 ? n : 2 ...

  8. ABAP内表数据做层次XML输出

      *&---------------------------------------------------------------------**& Report  Z_BARRY ...

  9. activiti--4----------------------------------流程变量

    一.流程变量的作用 1.用来传递业务参数 2.指定连线完成任务(同意或拒绝) 3.动态指定任务办理人 二.测试代码块 Person类 package com.xingshang.processVari ...

  10. python3函数内全局变量使用global

    def p_num(): global num num = 10 print (num) num = 5 p_num() print(num)