Euclid

    xiaoxiao2025-08-29  7

    Euclid

    . . 题意:给出A,B,C,D,E,F四个点,求AC射线上点H,使得ABHG是平行四边形且面积等于三角形DEF的面积 . . 解法:直接数学方法求就好了 . .

    #include <iostream> #include <stdio.h> #include <stdlib.h> #include <math.h> using namespace std; #define sqr(x) (x)*(x) struct point { double x, y; }; double dist(point t1, point t2) { return sqrt((t1.x-t2.x)*(t1.x-t2.x)+(t1.y-t2.y)*(t1.y-t2.y)); } point a, b, c, d, e, f, g, h; int main() { //freopen("a.in","r",stdin); while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", &a.x,&a.y,&b.x,&b.y,&c.x,&c.y,&d.x,&d.y,&e.x,&e.y,&f.x,&f.y) != EOF) { if (fabs(a.x)<1e-9 && fabs(a.y)<1e-9 && fabs(b.x)<1e-9 && fabs(b.y)<1e-9 && fabs(c.x)<1e-9 && fabs(c.y)<1e-9 && fabs(d.x)<1e-9 && fabs(d.y)<1e-9 && fabs(e.x)<1e-9 && fabs(e.y)<1e-9 && fabs(f.x)<1e-9 && fabs(f.y)<1e-9) break; double p = (dist(e, f)+dist(f, d)+dist(e, d))/2; double area = sqrt(p*(p-dist(e,f))*(p-dist(f, d))*(p-dist(e, d))); double high = area/dist(a, b); double co = ((b.x-a.x)*(c.x-a.x)+(b.y-a.y)*(c.y-a.y))/(dist(a,b)*dist(a,c)); double bili; if (fabs(co) < 1e-8) bili = high/dist(a,c); else bili = (high/sqrt(1-co*co))/dist(a,c); h.x = a.x+bili*(c.x-a.x); h.y = a.y+bili*(c.y-a.y); g.x = b.x+h.x-a.x; g.y = b.y+h.y-a.y; printf("%.3lf %.3lf %.3lf %.3lf\n", g.x, g.y, h.x, h.y); } }
    转载请注明原文地址: https://ju.6miu.com/read-1302101.html
    最新回复(0)