UVa 11731 - Ex-circles

给出三角形ABC的三条边长a,b,c,求外接三角形DEF的面积及阴影部分的面积


这题推了一个来小时,才观察到一个问题——把外切圆的圆心向对应的三条线引垂线,根据切线长定理可以判断出外切圆圆心为对应两个三角形外角角平分线的交点,这个规律推出来,后面的就很好做了


#include 
#include 
const double pi=acos(-1.0);
double area(double a,double b,double c)
{
    double p=(a+b+c)/2.0;
    return sqrt(p*(p-a)*(p-b)*(p-c));
}
double area2(double a,double B,double C)
{
    double A=pi-B-C;
    double b=a*sin(B)/sin(A);
    double c=a*sin(C)/sin(A);
    return area(a,b,c);
}
double area3(double a,double B,double C)
{
    double A=pi-B-C;
    double r=area2(a,B,C)/a*2.0;
    return r*r*A*0.5;
}
int main()
{
    int cas=0;
    double a,b,c,A,B,C,aa,bb,cc,sa,sb,sc;
    double ha,hb,hc;
    while(scanf("%lf%lf%lf",&a,&b,&c)==3)
    {
        if(!a&&!b&&!c)break;
        A=acos((b*b+c*c-a*a)/(2.0*b*c));
        B=acos((a*a+c*c-b*b)/(2.0*a*c));
        C=acos((a*a+b*b-c*c)/(2.0*a*b));
        aa=0.25*(2*pi-2.0*A);
        bb=0.25*(2*pi-2.0*B);
        cc=0.25*(2*pi-2.0*C);
        sa=area2(a,bb,cc);
        sb=area2(b,aa,cc);
        sc=area2(c,aa,bb);
        double s=area(a,b,c)+sa+sb+sc;
        double t=area3(a,bb,cc)+area3(b,aa,cc)+area3(c,aa,bb);
        printf("Case %d: %.2lf %.2lf\n",++cas,s,t);
    }

    return 0;
}


你可能感兴趣的:(几何)