%%%PoPoQQQ:http://blog.csdn.net/popoqqq/article/details/44346555
“首先两个复数相乘的几何意义是【极角相加,长度相乘】 这两种变换正好对应旋转和放缩
那么我们不妨将所有点都放到复平面上
由于没有给定点的对应关系,故我们3!枚举这个对应关系
设其中一个三角形的三个顶点为A,B,C,另一个三角形中对应顶点为A',B',C'
设中心点为P,变换复数为T
那么我们有方程组:
(A-P)T=(A'-P)
(B-P)T=(B'-P)
(C-P)T=(C'-P)
由前两个方程解得
T=(A'-B')/(A-B)
P=(AT-A')/(T-1)
代入第三个方程中验证即可。”
标准库的complex用的我蛋疼,还是要像Po姐一样自己打个complex类
#include<cstdio> #include<cmath> #include<cstring> #include<iostream> #include<algorithm> #include<complex> #define eps 1e-4 using namespace std; typedef complex<double> Complex; Complex A,B,C,point[4]; istream& operator >> (istream &_,Complex &c) { double r,i; scanf("%lf%lf",&r,&i); c=Complex(r,i); return _; } ostream& operator << (ostream &_,const Complex &c) { printf("%.6lf %.6lf",c.real(),c.imag()); return _; } bool operator == (const Complex &c1,const Complex &c2) { return fabs(c1.real()-c2.real())<eps && fabs(c1.imag()-c2.imag())<eps; } inline void Calc(Complex _A,Complex _B,Complex _C) { Complex T=(_A-_B)/(A-B),P=(A*T-_A)/(T-Complex(1,0)); if ((C-P)*T==(_C-P)) { cout<<P<<endl; throw true; } } int main() { int Q; freopen("t.in","r",stdin); freopen("t.out","w",stdout); cin>>Q; while (Q--) { cin>>A>>B>>C>>point[1]>>point[2]>>point[3]; try{ Calc(point[1],point[2],point[3]); Calc(point[1],point[3],point[2]); Calc(point[2],point[1],point[3]); Calc(point[2],point[3],point[1]); Calc(point[3],point[1],point[2]); Calc(point[3],point[2],point[1]); }catch(bool){} } return 0; }