UVALive 4642 (B) Malfatti Circles

公式:https://en.wikipedia.org/wiki/Malfatti_circles?setlang=zh-cn

// s=(a+b+c)/2;
// 内心r=sqrt(s*(s-a)*(s-b)*(s-c))/s;
// 内心坐标(a*x1+b*x2+c*x3)/(2*s),(a*y1+b*y2+c*y3)/(2*s);
// d=MA,e=MB,f=MC
// r1=r/(2*(s-a))*(s+d-r-e-f)
// r2=r/(2*(s-b))*(s+e-r-d-f)
// r3=r/(2*(s-c))*(s+f-r-d-e)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<complex>
using namespace std;
typedef complex<double> Point;
typedef Point Vector ;
const double eps=1e-6;
int dcmp(double x)
{
    if(fabs(x)<eps) return 0;
    else return x<0?-1:1;
}
double Dot(Vector A,Vector B)
{
    return real(conj(A)*B);
}
double Cross(Vector A,Vector B)
{
    return imag(conj(A)*B);
}
Vector Rotate(Vector A,double rad)
{
    return A*exp(Point(0,rad));
}
double Length(Vector A)
{
    return sqrt(Dot(A,A));
}
double Length(Point A,Point B)
{
    return Length(B-A);
}

int main()
{
    double a,b,c,d,e,f,r,r1,r2,r3,s;
    Point A,B,C,M;
    double x1,y1,x2,y2,x3,y3;
    while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3))
    {
        if(!dcmp(x1)&&!dcmp(y1)&&!dcmp(x2)&&!dcmp(y2)&&!dcmp(x3)&&!dcmp(y3))
            break;
      //  printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",x1,y1,x2,y2,x3,y3);
        A=Point(x1,y1),B=Point(x2,y2),C=Point(x3,y3);
        //cout<<A<<" "<<B<<" "<<C<<endl;
        a=Length(B,C),b=Length(A,C),c=Length(A,B);
        s=(a+b+c)/2;
        //cout<<s<<endl;
        r=sqrt(s*(s-a)*(s-b)*(s-c))/s;
        M=Point((a*x1+b*x2+c*x3)/2/s,(a*y1+b*y2+c*y3)/2/s);
        d=Length(A,M);
        e=Length(B,M);
        f=Length(C,M);
        r1=(r/2/(s-a))*(s+d-r-e-f);
        r2=(r/2/(s-b))*(s+e-r-d-f);
        r3=(r/2/(s-c))*(s+f-r-d-e);
        printf("%.6lf %.6lf %.6lf\n",r1,r2,r3);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值