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. iOS 添加震动效果

    开发过程中,有时候会碰到点击按钮或者某个动画会配合震动效果:下面介绍iOS开发过程中的震动添加: 导入:#import <AudioToolbox/AudioToolbox.h> 在需要出 ...

  2. iOS Load方法 和 initialize方法的比较

    一.load方法特点: 1. 当类被引用进程序的时候会执行这个函数 2.一个类的load方法不用写明[super load],父类就会收到调用,并且在子类之前. 3.Category的load也会收到 ...

  3. VS2017下编译iconv

    从http://www.gnu.org/software/libiconv/ 下载 libiconv-1.11.1, 这是最后一个支持MSVC编译的版本. 打开 Visual Studio 2017 ...

  4. 程序运行之ELF 符号表

    当一个工程中有多个文件的时候,链接的本质就是要把多个不同的目标文件相互粘到一起.就想玩具积木一样整合成一个整体.为了使不同的目标文件之间能够相互粘合,这些目标文件之间必须要有固定的规则才行.比如目标文 ...

  5. Unknown Entity namespace alias 'BaseMemberBundle'.

    $em = $this->getDoctrine()->getManager('member');//要记得写上member $repo = $em->getRepository(' ...

  6. iOS8 with Swift

    Ref:iOS8 Day-by-Day Ref:iOS8-day-by-day source Ref:Let's Swift Ref:Swift 代码库 Ref:iOS Apprentice Thir ...

  7. Apache Shiro 使用手册(五)Shiro 配置说明(转发:http://kdboy.iteye.com/blog/1169637)

    Apache Shiro的配置主要分为四部分: 对象和属性的定义与配置 URL的过滤器配置 静态用户配置 静态角色配置 其中,由于用户.角色一般由后台进行操作的动态数据,因此Shiro配置一般仅包含前 ...

  8. Intel IPP 图像空间转换

    一. 背景 用QuickSync VPP模块做RGBA到NV12的颜色空间转换导致文字显示蒙上一层颜色的问题, 暂时怀疑是VPP自身的问题,因为参数设置都是按官方demo设置的.所以尝试使用IPP来做 ...

  9. 数据库存储I/O类型分析与配置

    存储设备作为数据的容器,为应用提供数据存取服务,而存储系统将数据展现给不同的应用后,应用程序对数据访问不尽相同.简要来说,就是读和写,更加细分的话是以不同的传输单元(I/O大小)进行顺序和随机类型的读 ...

  10. C# 串口调试助手源码

    本方法,禁用跨进程错误(做法不太好,但是对于单片机出身的人来说,好理解,能用就行). 基本功能: 1.点串口号的下拉菜单自动当前检索设备管理器的COM 2.发送模式可选,hex和string两种 3. ...