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; }

最新文章

  1. shell 带签名请求,yii 处理带签名的请求
  2. Android SDK升级后报错error when loading the sdk 发现了元素 d:skin 开头无效内容
  3. dl dt dd定义
  4. 【BZOJ】2002: [Hnoi2010]Bounce 弹飞绵羊(lct)
  5. SparkStreaming结合Kafka使用
  6. power desinger 学习笔记&lt;六&gt;
  7. &#183; HTML使用Viewport
  8. python成长之路11
  9. hdu1151Air Raid
  10. Hybrid容器设计之第三方网站
  11. 【XSY2851】蛋糕 数学
  12. 数学模块_math
  13. 用BlockingQueue实现的简单发布订阅模式
  14. 【比赛】NOIP2018 铺设道路
  15. Hdoj 1232.畅通工程 题解
  16. Vue.js项目脚手架构建
  17. 使用SSH远程登陆Linux
  18. Python 命名笔记
  19. 使用pip install XX 命令时报错
  20. Spring Boot 简单的请求示例(包括请求体验证)

热门文章

  1. [OpenCV] Samples 15: Background Subtraction and Gaussian mixture models
  2. win7+ oracle +php环境的搭建
  3. Python 扩展知识
  4. CentOS7安装ipython
  5. socket 中文man页面函数
  6. 深入浅出MFC——MFC六大关键技术仿真(二)
  7. javascript/css压缩工具---yuicompressor使用方法
  8. java 对 汉字排序(按照拼音字母排序)
  9. css !important用法以及CSS样式使用优先级判断
  10. Bootstrap学习总结笔记(24)-- 基于BootstrapValidator的Form表单验证