HDU 4998 Rotate
2014-09-20 09:34
302 查看
题目链接~~>
做题感悟:表示自己太弱了,模拟也没模拟出来,简单想法也没想到,而且是一大堆人在讨论。
解题思路:
平面每次绕一个点旋转,最终平面旋转的角度就是所有旋转的角度之和,这样你只需要设置一个起始点 x0 ,y0 ,在经过变换后变为 x1 ,y1 ,因为角度已经知道这样可以用坐标旋转的方程解出目标点( x , y )。
x1 = ( x0 - x ) * cos( a ) - ( y0 - y1 ) * sin( a ) + x ;
y1 = ( x0 - x ) * sin( a ) + ( y0 - y1 ) * sin( a ) + y ;
解二元一次方程即可。
代码:
做题感悟:表示自己太弱了,模拟也没模拟出来,简单想法也没想到,而且是一大堆人在讨论。
解题思路:
平面每次绕一个点旋转,最终平面旋转的角度就是所有旋转的角度之和,这样你只需要设置一个起始点 x0 ,y0 ,在经过变换后变为 x1 ,y1 ,因为角度已经知道这样可以用坐标旋转的方程解出目标点( x , y )。
x1 = ( x0 - x ) * cos( a ) - ( y0 - y1 ) * sin( a ) + x ;
y1 = ( x0 - x ) * sin( a ) + ( y0 - y1 ) * sin( a ) + y ;
解二元一次方程即可。
代码:
#include<iostream> #include<sstream> #include<map> #include<cmath> #include<fstream> #include<queue> #include<vector> #include<sstream> #include<cstring> #include<cstdio> #include<stack> #include<bitset> #include<ctime> #include<string> #include<iomanip> #include<algorithm> using namespace std ; #define INT long long int const int INF = 99999999 ; const double esp = 0.00000001 ; const double PI = acos(-1.0) ; const int MP = 2000000 + 5 ; const int MY = 200000 + 5 ; const int MX = 10000 + 5 ; int n ; struct Point { double x ,y ; } ; int main() { //freopen("input.txt" ,"w" ,stdout) ; int Tx ; scanf("%d" ,&Tx) ; while(Tx--) { scanf("%d" ,&n) ; double P = 0 ,x0 = 0 ,y0 = 0 ,xa ,ya ,pi ,x ,y ; for(int i = 0 ;i < n ; ++i) { scanf("%lf%lf%lf" ,&x ,&y ,&pi) ; P += pi ; if(P >= 2.0*PI) P -= 2.0*PI ; xa = (x0 - x)*cos(pi) - (y0 - y)*sin(pi) + x ; ya = (x0 - x)*sin(pi) + (y0 - y)*cos(pi) + y ; x0 = xa ; y0 = ya ; } double PX = (x0*(1-cos(P))-y0*sin(P))/(2.0-2.0*cos(P)) ; double PY = (x0+PX*cos(P)-PX)/sin(P) ; cout<<fixed<<setprecision(10)<<PX<<" "<<PY<<" "<<P<<endl ; } return 0 ; }
相关文章推荐
- HDU 4998 Rotate
- HDU 4998 Rotate(计算几何/绕弧度旋转/模板的巧用)
- 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 (几何变换——旋转)
- HDU 4998 Rotate
- HDU 4998 Rotate (二维图形几何变换)
- HDU 4998 Rotate
- HDU 4998 Rotate(计算几何 绕点旋转)
- HDU 4998 (点的旋转) Rotate
- HDU 4998 Rotate --几何
- HDU 4998 Rotate(计算几何 绕点旋转)
- HDU 4998 Rotate(鞍山网络赛B题)