Rotate

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1232    Accepted Submission(s): 545
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 :).

 
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
 
Source
题意:在平面上给你n个点,每个点都有一个对应的弧度,问整个平面依次绕每个点逆时针旋转对应的弧度
最后相当于对哪个点旋转了多少弧度?
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set> #define MM(a,b) memset(a,b,sizeof(a));
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define CT continue
#define SC scanf const double eps=1e-8;
const double pi=acos(-1);
int cas,n; struct Point{
double x,y,pi;
void read(){
SC("%lf%lf%lf",&x,&y,&pi);
}
}p[15]; int dcmp(double a)
{
if(fabs(a)<eps) return 0;
else return a>0?1:-1;
} double dot(Point a,Point b)
{
return a.x*b.x+a.y*b.y;
} double Length(Point a)
{
return sqrt(a.x*a.x+a.y*a.y);
} Point operator*(double k,Point a)
{
return (Point){k*a.x,k*a.y,0};
} Point operator-(Point a,Point b)
{
return (Point){a.x-b.x,a.y-b.y,0};
} Point operator+(Point a,Point b)
{
return (Point){a.x+b.x,a.y+b.y,0};
} Point Rotate(Point a,double rad)
{
return (Point){a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad),0};
} Point Normal(Point a)
{
double L=Length(a);
return (Point){-a.y/L,a.x/L,0};
} void R(Point &s,Point &t,Point &nor,Point &mid)
{
s=p[0];
for(int i=1;i<=n;i++){
Point v=p[0]-p[i];
v=Rotate(v,p[i].pi);
p[0]=p[i]+v;
}
t=p[0];
nor=Normal(t-s),mid=(Point){(s.x+t.x)/2,(s.y+t.y)/2,0};
} double cross(Point a,Point b)
{
return a.x*b.y-b.x*a.y;
} Point Getlineintersection(Point p,Point v,Point q,Point w)
{
Point u=p-q;
double t=cross(w,u)/cross(v,w);
return p+t*v;
} int main()
{
SC("%d",&cas);
while(cas--)
{
SC("%d",&n);
for(int i=1;i<=n;i++) p[i].read();
Point s1,t1,s2,t2,nor1,nor2,mid1,mid2,o;
p[0]={12,9,0};
R(s1,t1,nor1,mid1);
p[0]={3,17,0};
R(s2,t2,nor2,mid2); o=Getlineintersection(mid1,nor1,mid2,nor2);
Point os=s1-o,ot=t1-o; double ang,ang1=atan2(os.y,os.x),ang2=atan2(ot.y,ot.x);
if(dcmp(ang1-ang2)>0) ang=ang1-ang2;
else ang=ang2-ang1; if(dcmp(cross(t1-s1,o-s1))>0){
if(dcmp(ang-pi)>0) ang=2*pi-ang;
}
else {
if(dcmp(pi-ang)>0) ang=2*pi-ang;
} if(dcmp(o.x)==0) o.x=0;
if(dcmp(o.y)==0) o.y=0;
printf("%.10f %.10f %.10f\n",o.x,o.y,ang);
}
return 0;
}

  1.因为题目保证有解,所以在平面上任取两点,求出旋转后的弧度,那么最后选装的圆心必定在两条

从起点到终点的中垂线上

2.找到圆心后,再依据圆心在向量st的左侧还是右侧确定旋转的弧度是>pi还是小于pi。

3.最后因为double表示数据时,0可能是2*1e-30,按%.10f输出则是-0.00000000,所以需要

在最后判断一下。

hdu 4998 Rotate 点的旋转 银牌题的更多相关文章

  1. HDU 4998 Rotate (计算几何)

    HDU 4998 Rotate (计算几何) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4998 Description Noting is more ...

  2. HDU 4998 Rotate --几何

    题意:给n个点(x,y,p),从1~n,一次每次所有点绕着第 i 个点(原来的)逆时针转pi个弧度,问最后所有点的位置相当于绕哪个点旋转多少弧度,求出那点X和弧度P 解法:直接模拟旋转,每次计算新的坐 ...

  3. HDU 4998 Rotate

    题意: n次旋转  每次平面绕ai点旋转pi弧度  问  最后状态相当于初始状态绕A点旋转P弧度  A和P是多少 思路: 如果初始X点的最后状态为X'点  则圆心一定在X和X'连线的垂直平分线上  那 ...

  4. HDU 2096 小明A+B --- 水题

    HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...

  5. HDU 1248 寒冰王座(全然背包:入门题)

    HDU 1248 寒冰王座(全然背包:入门题) http://acm.hdu.edu.cn/showproblem.php?pid=1248 题意: 不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票 ...

  6. HDU 4998 (点的旋转) Rotate

    为了寻找等效旋转操作,我们任选两个点P0和Q0,分别绕这n个点旋转一定的角度后最终得到Pn和Qn 然后已知:P0和Pn共圆,Q0和Qn共圆.所以要找的等效旋转点就是这两个线段的垂直平分线交点O. 等效 ...

  7. hdu 4998 矩阵表示旋转

    http://acm.hdu.edu.cn/showproblem.php?pid=4998 http://blog.csdn.net/wcyoot/article/details/33310329 ...

  8. hdu 5514 Frogs 容斥思想+gcd 银牌题

    Frogs Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submi ...

  9. hdu 4998

    http://acm.hdu.edu.cn/showproblem.php?pid=4998 这道题,在比赛的时候看了很久,才明白题目的大意.都怪自己不好好学习英语.后来经过队友翻译才懂是什么意思. ...

随机推荐

  1. MySQL_Utilities工具

    需求    Python 2.6    MySQL Connector/Python 连接器 下载地址:    http://dev.mysql.com/downloads/utilities/   ...

  2. DVWA漏洞演练平台 - 文件上传

    DVWA(Damn Vulnerable Web Application)是一个用来进行安全脆弱性鉴定的PHP/MySQL Web应用,旨在为安全专业人员测试自己的专业技能和工具提供合法的环境,帮助w ...

  3. Git安装使用秘籍

    首先Git的功能,是用于帮助用户实现版本控制的软件,GIT一般和GitHub配套使用.Git是个软件,GitHub是个网站,它们的关系就像雷锋与雷峰塔一样,没什么关系.本文只提供Git安装方法,其它请 ...

  4. 优化方法总结以及Adam存在的问题(SGD, Momentum, AdaDelta, Adam, AdamW,LazyAdam)

    优化方法总结以及Adam存在的问题(SGD, Momentum, AdaDelta, Adam, AdamW,LazyAdam) 2019年05月29日 01:07:50 糖葫芦君 阅读数 455更多 ...

  5. 使ul中的li居中

    1.如果li设置了float:left; 解决办法: 1.ul父元素的标签设置:text-align: center; 2.ul设置: display: inline-block; 2.li不设置fl ...

  6. Lua的栈及基本栈操作

    Lua的栈及基本栈操作 https://blog.csdn.net/mydriverc2/article/details/51134737 https://blog.csdn.net/mydriver ...

  7. Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

    Java StackTraceElement stack[] = Thread.currentThread().getStackTrace(); System.out.println("Ca ...

  8. 【Struts2】进阶

    一.Action处理请求参数 1.1 属性驱动 1.2 模型驱动 1.3 扩展 将数据封装到List集合 将数据封装到Map集合 二.类型转换 2.1 自定义类型转换器: 1.创建一个自定义类型转换器 ...

  9. Junit5常用注解

    0. IDEA中Maven项目测试类的新建方法 a. 如图在src目录下新建文件夹test b. 鼠标右键test,将该文件设置成test source c. 右键需要新建的测试类,如下图操作,选中T ...

  10. 《浏览器工作原理与实践》<02>TCP协议:如何保证页面文件能被完整送达浏览器?

    前言: 在衡量 Web 页面性能的时候有一个重要的指标叫“FP(First Paint)”,是指从页面加载到首次开始绘制的时长.这个指标直接影响了用户的跳出率,更快的页面响应意味着更多的 PV.更高的 ...