题意:

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. Element.Event

    addEvent(type,fn):为DOM元素增加一个事件监听器 removeEvent(type,fn):移除先前为DOM元素添加的事件监听器 eg: var destroy = function ...

  2. openCV中cvSnakeImage()函数代码分析

    /*M/////////////////////////////////////////////////////////////////////////////////////// // // IMP ...

  3. php与文件操作

    一.目录操作 首先是从目录读取的函数,opendir(),readdir(),closedir(),使用的时候是先打开文件句柄,而后迭代列出: <?php $base_dir="fil ...

  4. jquery实现鼠标焦点十字效果

    系统开发时很多地方需要有焦点效果,例如:鼠标点击聚焦,地图定位,在图片上突出显示,焦点定位页面元素. 本小功能通过jquery和graphics二次开发,实现通过鼠标点击页面任何区域,聚焦当前点击位置 ...

  5. SetFocus、SetCapture和SetActiveView的区别

    1. SetActiveView是MFC框架内的一个函数, 而不是SDK中的函数, 也就是说SDK中没有ActiveView这个概念, 只有在MFC中才有2. SetFocus是SDK中的函数(当然M ...

  6. clearcase 中一些概念和操作

    clearcase 中一些概念和操作 视图 常用命令 ClearCase 安装和使用的一些FAQ 参考 ClearCase具体的说是做配置管理的工具,只是SCM管理工具其中的一种.是RATIONAL公 ...

  7. 什么是VSync

    VSync是垂直同期(Vertical Synchronization)的简称.主要的思路是将你的FPS和显示器的刷新率同期起来.其目的是避免一种称之为"撕裂"的现象.再以下我将具 ...

  8. 浅解ARC中的 __bridge、__bridge_retained和__bridge_transfer

    文章来源:http://www.outflush.com/2015/03/introduction-of-arc-bridge-type-transfer/ 在对 bridge 相关的修饰符解说前.首 ...

  9. Redis Destop Manager不能访问虚拟机

    虚拟机centOS中安装Redis,主机Redis Destop Manager不能访问虚拟机Redis server的解决方案 今天在学些redis的时候碰到个问题,发现主机Redis Destop ...

  10. Enthought科学计算,数据分析

    Enthought Canopy: Easy Python Deployment Plus Integrated Analysis Environment for Scientific Computi ...