HDU 4998 (点的旋转) Rotate
2014-09-13 22:31
274 查看
为了寻找等效旋转操作,我们任选两个点P0和Q0,分别绕这n个点旋转一定的角度后最终得到Pn和Qn
然后已知:P0和Pn共圆,Q0和Qn共圆。所以要找的等效旋转点就是这两个线段的垂直平分线交点O。
等效的角度的计算,可以利用已知的等腰三角形(这里有两个)△P0PnR,做一条垂线(三线合一的性质),再利用反三角函数计算半角,再乘二
还有一种特殊情况就是,如果答案比平角要大,我们计算的角度就不对了。
此时可以让P0逆时针旋转90°得到一个P1,然后将P1和Pn的坐标分别代入直线P0R的方程,如果异号,说明P1和Pn在直线两侧;同号说明同侧。
也就是异侧的话,就要将所求角度用2π减去它。
外来的代码君
然后已知:P0和Pn共圆,Q0和Qn共圆。所以要找的等效旋转点就是这两个线段的垂直平分线交点O。
等效的角度的计算,可以利用已知的等腰三角形(这里有两个)△P0PnR,做一条垂线(三线合一的性质),再利用反三角函数计算半角,再乘二
还有一种特殊情况就是,如果答案比平角要大,我们计算的角度就不对了。
此时可以让P0逆时针旋转90°得到一个P1,然后将P1和Pn的坐标分别代入直线P0R的方程,如果异号,说明P1和Pn在直线两侧;同号说明同侧。
也就是异侧的话,就要将所求角度用2π减去它。
#include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bitset> #include <list> #include <stdexcept> #include <functional> #include <utility> #include <ctime> #include <cassert> #include <complex> using namespace std; #define rep(i,a,n) for (int i=a;i<n;i++) #define per(i,a,n) for (int i=n-1;i>=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) #define ACCU accumulate #define TWO(x) (1<<(x)) #define TWOL(x) (1ll<<(x)) #define clr(a) memset(a,0,sizeof(a)) #define POSIN(x,y) (0<=(x)&&(x)<n&&0<=(y)&&(y)<m) #define PRINTC(x) cout<<"Case #"<<++__<<": "<<x<<endl #define POP(x) (__builtin_popcount(x)) #define POPL(x) (__builtin_popcountll(x)) typedef vector<int> VI; typedef vector<string> VS; typedef vector<double> VD; typedef long long ll; typedef long double LD; typedef pair<int,int> PII; typedef pair<ll,ll> PLL; typedef vector<ll> VL; typedef vector<PII> VPII; typedef complex<double> CD; const int inf=0x20202020; const ll mod=1000000007; const double eps=1e-9; const double pi=3.1415926535897932384626; const int DX[]={1,0,-1,0},DY[]={0,1,0,-1}; ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} // head int _,n; CD k,b,p; double x,y,c; int main() { for (scanf("%d",&_);_;_--) { k=CD(1,0);b=CD(0,0); scanf("%d",&n); rep(i,0,n) { scanf("%lf%lf%lf",&x,&y,&c); p=CD(x,y); k=k*CD(cos(c),sin(c)); b=(b-p)*CD(cos(c),sin(c))+p; } double the=arg(k); while (the<0) the+=2*pi; while (the>=2*pi) the-=2*pi; p=b/(CD(1,0)-k); printf("%.10f %.10f %.10f\n",real(p),imag(p),the); } }
外来的代码君
相关文章推荐
- 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(计算几何)2014年鞍山赛区网络赛
- HDU 4998 Rotate --几何
- hdu 4998 Rotate 2014 ACM/ICPC Asia Regional Anshan Online
- 【几何模板加点小思路】hdu-4998 Rotate
- HDU 4998 Rotate (2014年鞍山赛区网络赛B题)
- HDU 4998 Rotate
- HDOJ 4998 Rotate(求直线交点、绕定点旋转)
- HDU 4998 Rotate 计算几何
- HDU 4998 Rotate(鞍山网络赛B题)
- HDU 4998 Rotate (二维图形几何变换)
- hdu 4998 Rotate(计算几何)