HDU 4998 Rotate 计算几何
来源:互联网 发布:java直播源码 编辑:程序博客网 时间:2024/06/06 10:55
当题意就是一个物体每次绕着一个点旋转一个角度,旋转n次后等价于从开始状态绕一个点旋转一定角度后直接到达最终状态。求这个点的坐标和旋转角度。
当时做的时候就自己yy了一个做法就在那搞,,没想到居然过了,现在来看我都有点佩服自己当时是怎么想的了。
#include<stdio.h>#include<math.h>#define PI 3.1415926535struct s{ double xx,yy;};s f1(s l,s r,double p0){ s temp; l.xx-=r.xx; l.yy-=r.yy; temp.xx=l.xx*cos(p0)-l.yy*sin(p0); temp.yy=l.xx*sin(p0)+l.yy*cos(p0); temp.xx+=r.xx; temp.yy+=r.yy; return temp;}int main(){ int n,T; double z,ans,x,y,le; s k,t,r,mid,con; scanf("%d",&T); while(T--) { t.xx=0; t.yy=110; ans=0; scanf("%d",&n); while(n--) { scanf("%lf%lf%lf",&k.xx,&k.yy,&z); ans+=z; if(ans>=2*PI) ans-=2*PI; t=f1(t,k,z); } mid.xx=(t.xx)/2; mid.yy=(t.yy+110)/2; if(t.xx==0) { con.yy=mid.yy; con.xx=( t.xx+(110-con.yy)*sin(ans) )/(1-cos(ans)) ; } else if(t.yy==110) { con.xx=mid.xx; con.yy=(t.yy+con.xx*sin(ans) )/(cos(ans)+1 ); } else { le=(t.yy-110)/(t.xx); // printf("%lf\n",le); double b=mid.yy+mid.xx/le; le=-1*(1/le); // printf("%lf %lf\n",le,b); con.xx=(-1*t.xx-(110-b)*sin(ans))/(cos(ans)-1-sin(ans)*le); con.yy=le*con.xx+b; } printf("%.10lf %.10lf %.10lf\n",con.xx,con.yy,ans); } 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(计算几何 绕点旋转)
- 【计算几何】 HDOJ 4998 Rotate
- HDU 4998 Rotate 计算几何 2014 ACM/ICPC Asia Regional Anshan Online
- HDU 4998 Rotate(计算几何)2014年鞍山赛区网络赛
- HDU 4998 Rotate(计算几何/绕弧度旋转/模板的巧用)
- HDU 4998 Rotate 简单几何旋转问题
- hdu 4998 简单计算几何
- HDU 4998 Rotate (二维图形几何变换)
- HDU 4998 Rotate (几何变换——旋转)
- hdu4998 Rotate(计算几何+模拟)
- hdu 3952 计算几何
- HDU 3694计算几何
- 解决ubuntu14.04下Qt 5.3.1下的QtCreator fcitx不能输入中文
- UNIX环境高级编程-第7章- 进程环境
- 读取机器人关机位置,用MATLAB换算成关节速度数据
- 社説 20141220 米キューバ接近 冷戦の残滓解消に課題は残る
- Solr Searching
- HDU 4998 Rotate 计算几何
- 关于<<JavaScript高级程序设计>>第三版中apply的一个错误
- 社説 20141220 STAP作れず 細胞の正体は何だったのか
- 在海思3512平台实现通过3G网络远程升级程序
- JavaScript学习-- 3. 变量
- 一般c++编译出现"name lookup of '变量名' changed [enabled by default]"的警告
- 忆王孙 稼轩
- Unity3D模型制作规范
- hdu1874畅通工程续(Floyed)