题意
求矩形M和矩形N中相对位置不变的点
思路
形如
解为
代码
#include <bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define debug system("pause")
#define ll long long
#define endl "\n"
struct point{
int x,y;
};
void solve(){
point A,B,C,D,a,b,c,d;
cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>D.x>>D.y
>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y;
int a_=C.x-c.x+d.x-D.x;
int b_=A.x-a.x+d.x-D.x;
int c_=d.x-D.x;
int d_=C.y-c.y+d.y-D.y;
int e_=A.y-a.y+d.y-D.y;
int f_=d.y-D.y;
double y=(f_-d_*c_*1.0/a_)/(e_-d_*b_*1.0/a_);
double x=(c_-b_*y)/a_;
double ans1 = D.x + x*(C.x-D.x)+y*(A.x-D.x);
double ans2 = D.y + x*(C.y-D.y)+y*(A.y-D.y);
cout<<fixed<<setprecision(6)<<ans1<<" "<<ans2<<endl;
}
int main(){
js;
int T;cin>>T;
while(T--) solve();
debug;
}