HDU 4998 Rotate
来源:互联网 发布:windows无法识别u盘 编辑:程序博客网 时间:2024/06/07 01:49
Rotate
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1116 Accepted Submission(s): 503
Special Judge
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 :).
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π.
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.
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
130 0 11 1 12 2 1
Sample Output
1.8088715944 0.1911284056 3.0000000000
Source
2014 ACM/ICPC Asia Regional Anshan Online
Recommend
hujie | We have carefully selected several similar problems for you: 5751 5750 5749 5748 5747
计算几何,有一个点,绕着另一个点旋转了p角度。并且旋转了n次。问最初这个点等价于绕哪个点旋转n角度和那个等价。
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<vector>#include<map>#include<set>#include<queue>#include<stack>#include<string>#include<algorithm>using namespace std;#define N 100050typedef long long ll;const int MOD = 1e9+7;#define PI acos(-1)int main(){ double start_x, start_y; double final_x, final_y; double x, y, p; double final_jiao, xx, yy; int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); start_x=start_y=xx=yy=1; //随便设立 final_jiao=0; while(n--) { scanf("%lf %lf %lf",&x,&y,&p); final_jiao+=p; if(final_jiao>=2*PI) final_jiao-=2*PI; final_x=(xx-x)*cos(p)-(yy-y)*sin(p)+x; // x0= (x - xx)*cos(a) - (y - yy)*sin(a) + xx ; 设x,y绕着点xx,yy转了p角度。则x0,y0为新的点。 final_y=(xx-x)*sin(p)+(yy-y)*cos(p)+y; // y0= (x - xx)*sin(a) + (y - yy)*cos(a) + yy ; xx=final_x; yy=final_y; } // 换下公式,相当于在一开始的点然后找一个点旋转使得最后的点为fianl_x,final_y //则可以推出 x=((final_x-start_x*cos(final_jiao)+start_y*sin(final_jiao))*(1-cos(final_jiao))-(final_y-start_x*sin(final_jiao)-start_y*cos(final_jiao))*sin(final_jiao))/(2-2*cos(final_jiao)); y=((final_x-start_x*cos(final_jiao)+start_y*sin(final_jiao))*(1-cos(final_jiao))-(1-cos(final_jiao))*(1-cos(final_jiao))*x)/((1-cos(final_jiao))*sin(final_jiao)); printf("%.12lf %.12lf %.12lf\n",x,y,final_jiao); } return 0;}
0 0
- HDU 4998 Rotate
- HDU 4998 Rotate
- HDU 4998 Rotate
- HDU 4998 Rotate
- hdu 4998 Rotate(几何)
- HDU 4998 Rotate
- hdu 4998 Rotate
- HDU 4998 Rotate --几何
- HDU 4998 Rotate
- hdu 4998——Rotate
- HDU 4998 Rotate 平面旋转
- HDU 4998 Rotate 计算几何
- HDU 4998 Rotate 平面坐标变换
- hdu 4998 Rotate(计算几何)
- HDU 4998 Rotate 简单几何旋转问题
- hdu 2688 Rotate
- hdu 2688 Rotate
- hdu 2688 Rotate
- postgreSQL触发器
- 性能优化——布局优化
- HDU 5748 Bellovin(LIS)
- DialogInterface点击事件和View点击事件冲突问题
- Android 别人那里学习到的回调机制
- HDU 4998 Rotate
- Hibernate学习笔记----HQL(2)
- 国内一线互联网公司内部面试题库
- Android自定义View 简单实现多图片选择控件
- js 选项卡举例
- hadoop使用心得总结
- [CityHunter]游戏流程设计及技术要点
- 【CDP-云设计模式】第5章,3.私有分配模式(Private Distribution Pattern)
- 远程host改变后,本机ssh相应修改