题意:

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. Shell 输入/输出重定向

    大多数 UNIX 系统命令从你的终端接受输入并将所产生的输出发送回​​到您的终端.命令通常从标准输入的地方读取输入,默认是终端.标准输出,默认情况下是终端. 重定向命令列表如下: 命令 说明 comm ...

  2. OCA读书笔记(2) - 安装Oracle软件

    Objectives: •Describe your role as a database administrator (DBA) and explain typical tasks and tool ...

  3. [置顶] android之Notification版本兼容性问题

    首先先来创建一个notification提示 //概要 String tickerText = context.getResources().getText(R.string.app_name).to ...

  4. Swift - 启动时的向导页(新手引导)的制作

    在很多iOS产品或者一些应用版本的升级中,新手指导都是一个常用的功能,通过说明页的左右滑动,可以很清晰的展示系统的一些功能特性.制作思路如下: 1,如何检测应用是第一次登陆启动 我们可以使用NSUse ...

  5. 【deep learning学习笔记】注释yusugomori的LR代码 --- LogisticRegression.h

    继续看yusugomori的代码,看逻辑回归.在DBN(Deep Blief Network)中,下面几层是RBM,最上层就是LR了.关于回归.二类回归.以及逻辑回归,资料就是前面转的几篇.套路就是设 ...

  6. rsync Backups for Windows

    Transfer your Windows Backups to an rsync server over SSH rsync.net provides cloud storage for offsi ...

  7. CImage类

    CImage封装了DIB(设备无关位图)的功能,因而可以让我们能够处理每个位图像素.这里介绍GDI+和CImage的一般使用方法和技巧. TAG: GDI  CImage  后处理   我们知道,Vi ...

  8. android onKeydown

    package wyf.ytl; import android.app.Activity; import android.content.Context; import android.os.Bund ...

  9. Android应用开发学习笔记之ContentProvider

    作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz ContentProvider用于为其它应用程序提供共享数据,它为不同应用程序间共享数据提供了统一的操作接口. 一. ...

  10. HTML 页面载入 Flash 插件的几种方法

    前言 之所以写这篇文章,主要是由于组长给提的一个新的需求--使用浏览器调用电脑的摄像头,来实现即时拍照的功能.在网上查了非常多资料,由于这样那样的原因,终于选择了使用flash插件来调用pc的摄像头. ...