HDU 4998 Rotate 计算几何
2014-12-20 16:07
405 查看
当题意就是一个物体每次绕着一个点旋转一个角度,旋转n次后等价于从开始状态绕一个点旋转一定角度后直接到达最终状态。求这个点的坐标和旋转角度。
当时做的时候就自己yy了一个做法就在那搞,,没想到居然过了,现在来看我都有点佩服自己当时是怎么想的了。
当时做的时候就自己yy了一个做法就在那搞,,没想到居然过了,现在来看我都有点佩服自己当时是怎么想的了。
#include<stdio.h> #include<math.h> #define PI 3.1415926535 struct 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; }
相关文章推荐
- hdu 4998 Rotate 计算几何 点的旋转
- HDU 4998 Rotate 计算几何 2014 ACM/ICPC Asia Regional Anshan Online
- HDU 4998 Rotate(计算几何/绕弧度旋转/模板的巧用)
- HDU 4998 Rotate(计算几何 绕点旋转)
- hdu 4998 Rotate(计算几何)
- HDU 4998 Rotate(计算几何)2014年鞍山赛区网络赛
- HDU 4998 Rotate(计算几何 绕点旋转)
- 【几何模板加点小思路】hdu-4998 Rotate
- HDU 4998 Rotate (二维图形几何变换)
- hdu 4998 Rotate(几何)
- 【计算几何】 HDOJ 4998 Rotate
- HDU 4998 Rotate --几何
- HDU 4998 Rotate 简单几何旋转问题
- hdu 4998 简单计算几何
- HDU 4998 Rotate --几何
- HDU 1756 Cupid's Arrow 计算几何
- hdu 1700 Points on Cycle<计算几何>
- [计算几何] hdu 4380 Farmer Greedy
- HDU 1086 计算几何 求线段交点(吉大模板)
- HDU 4410 Boomerang(计算几何)(2012杭州网络赛1001)