题意:

n次旋转  每次平面绕ai点旋转pi弧度  问  最后状态相当于初始状态绕A点旋转P弧度  A和P是多少

思路:

如果初始X点的最后状态为X‘点  则圆心一定在X和X'连线的垂直平分线上  那么仅仅要用在取一个点Y和Y'  相同做它的垂直平分线  两线交点即是圆心  然后用简单几何方法算出角度  最后注意要求最后状态由最初状态逆时针旋转得到  适当调整角度就可以

PS:

kuangbin巨巨的几何代码还是非常easy理解的  非常好用~  谢谢~

代码:

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<cassert>
using namespace std;
typedef long long LL;
#define Q 401
#define N 51
#define M 200001
#define inf 2147483647
#define lowbit(x) (x&(-x)) const double eps = 1e-5;
const double PI = acos(-1.0); int sgn(double x) {
if (fabs(x) < eps)
return 0;
if (x < 0)
return -1;
else
return 1;
} struct Point {
double x, y;
Point() {
}
Point(double _x, double _y) {
x = _x;
y = _y;
}
Point operator +(const Point &b) const {
return Point(x + b.x, y + b.y);
}
Point operator -(const Point &b) const {
return Point(x - b.x, y - b.y);
}
//叉积
double operator ^(const Point &b) const {
return x * b.y - y * b.x;
}
//点积
double operator *(const Point &b) const {
return x * b.x + y * b.y;
}
//绕原点逆时针旋转角度B(弧度值)。后x,y的变化
void transXY(double B) {
double tx = x, ty = y;
x = tx * cos(B) - ty * sin(B);
y = tx * sin(B) + ty * cos(B);
}
} a1, a2, b1, b2, f1, f2, f3;
struct Line {
Point s, e;
Line() {
}
Line(Point _s, Point _e) {
s = _s;
e = _e;
}
//两直线相交求交点
//第一个值为0表示直线重合,为1表示平行,为2是相交
//仅仅有第一个值为2时。交点才有意义
pair<int, Point> operator &(const Line &b) const {
Point res = s;
if (sgn((s - e) ^ (b.s - b.e)) == 0) {
if (sgn((s - b.e) ^ (b.s - b.e)) == 0)
return make_pair(0, res); //重合
else
return make_pair(1, res); //平行
}
double t = ((s - b.s) ^ (b.s - b.e)) / ((s - e) ^ (b.s - b.e));
res.x += (e.x - s.x) * t;
res.y += (e.y - s.y) * t;
return make_pair(2, res);
}
} l1, l2; //两点间距离
double dist(Point a, Point b) {
return sqrt((a - b) * (a - b));
} int t, n; int main() {
int i;
double x, y, z;
scanf("%d", &t);
while (t--) {
a1 = f1 = Point(5e5, 3e5);
a2 = f2 = Point(1e5, 6e5);
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%lf%lf%lf", &x, &y, &z);
f3 = Point(x, y);
f1 = f1 - f3;
f2 = f2 - f3;
f1.transXY(z);
f2.transXY(z);
f1 = f1 + f3;
f2 = f2 + f3;
}
b1 = a1 + f1;
b1.x /= 2;
b1.y /= 2;
b2 = f1;
b2 = b2 - b1;
b2.transXY(PI / 2);
b2 = b2 + b1;
l1 = Line(b1, b2);
b1 = a2 + f2;
b1.x /= 2;
b1.y /= 2;
b2 = f2;
b2 = b2 - b1;
b2.transXY(PI / 2);
b2 = b2 + b1;
l2 = Line(b1, b2);
pair<int, Point> res = l1 & l2;
i = res.first;
f3 = res.second;
assert(i == 2);
printf("%f %f ", f3.x, f3.y);
f2 = f1 + a1;
f2.x /= 2;
f2.y /= 2;
x = atan(dist(f1, f2) / dist(f2, f3)) * 2;
y = PI + PI;
while (x > y)
x -= y;
while (x < 0)
x += y;
a1 = a1 - f3;
a1.transXY(x);
a1 = a1 + f3;
a1 = a1 - f1;
if (sgn(a1.x) || sgn(a1.y))
x = PI + PI - x;
printf("%f\n", x);
}
return 0;
}

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 点的旋转 银牌题

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

  4. HDU 4998 (点的旋转) Rotate

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

  5. hdu 4998

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

  6. hdu 4998 矩阵表示旋转

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

  7. hdu第4场j.Let Sudoku Rotate

    Problem J. Let Sudoku Rotate Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...

  8. ACM学习历程—Rotate(HDU 2014 Anshan网赛)(几何)

    Problem Description Noting is more interesting than rotation! Your little sister likes to rotate thi ...

  9. HDU - 6341 多校4 Let Sudoku Rotate(状压dfs)

    Problem J. Let Sudoku Rotate Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K ...

随机推荐

  1. 基于visual Studio2013解决面试题之0403串联字符串

     题目

  2. 手动配置S2SH三大框架报错(三)

    十二月 08, 2013 10:24:43 下午 org.apache.catalina.core.AprLifecycleListener init 严重: An incompatible vers ...

  3. timeout connect 10000 # default 10 second time out if a backend is not found

    timeout connect <timeout> timeout contimeout <timeout> (deprecated) Set the maximum time ...

  4. Android WebView挂马漏洞--各大厂商纷纷落马

    本文章由Jack_Jia编写,转载请注明出处.   文章链接: http://blog.csdn.net/jiazhijun/article/details/11131891 作者:Jack_Jia ...

  5. UVA 1386 - Cellular Automaton(循环矩阵)

    UVA 1386 - Cellular Automaton option=com_onlinejudge&Itemid=8&page=show_problem&category ...

  6. Memcached 群集高可用性(HA)架构

    Memcache本身并不实现集群功能.假设你想使用Memcahce集群需要使用第三方软件或编程来实现自己的设计,这里将被用来memagent实现代理,memagent也被称为magent.我们注意到, ...

  7. struts2错误验证

    在登陆的时候一般要用错误验证功能.效果如图: 在action层的写法: this.addActionError("username或password错误"); 在jsp页面上取值: ...

  8. Oracle中四种循环(GOTO、For、While、Loop)

    DECLARE x number; BEGIN x:=9; <<repeat_loop>> --循环点 x:=x-1; DBMS_OUTPUT.PUT_LINE(X); IF ...

  9. 44个JAVA代码质量管理工具(转)

    1. CodePro AnalytixIt’s a great tool (Eclipse plugin) for improving software quality. It has the nex ...

  10. IOCP模型与网络编程

    IOCP模型与网络编程 一.前言:        在老师分配任务(“尝试利用IOCP模型写出服务端和客户端的代码”)给我时,脑子一片空白,并不知道什么是IOCP模型,会不会是像软件设计模式里面的工厂模 ...