RT,真的没看出来哪里错了 qwq。
以下是思路:
先求 S△DEF,得到平行四边形的高为 ∣AB∣S。
将 AB 逆时针旋转 90°,取其单位向量数乘上高得到平移量 v。
将 AB 平移 v,得到 IJ,与 AC 求交点得到点 H。
将 H 沿着 AB 平移得到 G,这里需要判一下是否满足题目给出的平行条件。
ps:题目翻译错误,待求点应该为 G 和 H。
过样例了,但是 udebug 上的没过。
初步判断是题面读错了或者是边界没判定好。因为错的点都错的很离谱。
如果需要的话,可以给出错误样例:In 云剪贴板
#include<bits/stdc++.h>
#define ll long long
const int A=1;
const int B=2;
const int C=3;
const int D=4;
const int E=5;
const int F=6;
const int G=7;
const int H=8;
const int I=9;
const int J=10;
using namespace std;
const int N=15;
const double eps=1e-8;
int sign(double x)
{
if(fabs(x)<eps) return 0;
return x>0?1:-1;
}
int cmp(double x,double y)
{
if(fabs(x-y)<eps) return 0;
return x<y?-1:1;
}
struct node
{
double x,y;
}a[N];
node operator+(node a,node b)
{
return {a.x+b.x,a.y+b.y};
}
node operator-(node a,node b)
{
return {a.x-b.x,a.y-b.y};
}
node operator*(node a,double b)
{
return {a.x*b,a.y*b};
}
node operator/(node a,double b)
{
return {a.x/b,a.y/b};
}
double operator&(node a,node b)
{
return a.x*b.x+a.y*b.y;
}
double operator*(node a,node b)
{
return a.x*b.y-a.y*b.x;
}
double area(node a,node b,node c)
{
return (b-a)*(c-a);
}
node rotate(node a,double x)
{
return {a.x*cos(x)-a.y*sin(x),a.x*sin(x)+a.y*cos(x)};
}
double getlen(node a)
{
return sqrt(a&a);
}
node vecI(node a)
{
return a/getlen(a);
}
node get_line_intersection(node p1,node v1,node p2,node v2)
{
double t=((p2-p1)*v2)/(v1*v2);
return p1+v1*t;
}
const double PI=acos(-1);
signed main()
{
while(true)
{
double sum=0;
for(int i=1;i<=6;i++) cin>>a[i].x>>a[i].y,sum+=fabs(a[i].x)+fabs(a[i].y);
if(sign(sum)==0) break;
double S=area(a[D],a[E],a[F])/2;
double h=S/getlen(a[B]-a[A]);
node v=vecI(rotate(a[B]-a[A],PI/2))*h;
a[I]=a[A]+v,a[J]=a[B]+v;
a[H]=get_line_intersection(a[A],a[C]-a[A],a[I],a[J]-a[I]);
a[G]=a[H]+(a[J]-a[I]);
if(!((a[B]-a[A])*(a[H]-a[G])==0 && (a[H]-a[A])*(a[G]-a[B])==0)) a[G]=a[H]+(a[I]-a[J]);
cout<<fixed<<setprecision(3)<<a[G].x<<' '<<a[G].y<<' '<<a[H].x<<' '<<a[H].y<<'\n';
}
return 0;
}
真心感谢!