UVA 11731 Ex-circles(旁切圆)

题目的意思是说,给你一个三角形的三边(保证数据合法),求它三个旁切圆圆心所围成的面积和图中灰色部分的面积。

内切圆的圆心是三条角平分线的交点,旁切圆的圆心是两个外角的角平分的交点。

推导出发现三角形AEC、BDC、AFB是相似的,可用余弦定理算出角度后利用正弦定理算出边长。

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>

using namespace std;

const double pi = acos(-1.0);

double anga, angb, angc;
double angd, ange, angf;
double a, b, c;
double AE, AF, BD, BF, CD, CE;
double DE, EF, FD;
double dsin, esin, fsin;
double rd, re, rf;


double GetArea(double a, double b, double c)
{
	double p = (a + b + c) / 2.0;
	return sqrt(p * (p - a) * (p - b) * (p - c));
}

double GetR(double a, double b, double c)
{
	return (2.0 * GetArea(a, b, c) / c);
}

void Calc()
{
	anga = acos((b * b + c * c - a * a) / (2.0 * b * c));
	angb = acos((a * a + c * c - b * b) / (2.0 * a * c));
	angc = pi - anga - angb;
	angd = (pi - anga) / 2.0;
	ange = (pi - angb) / 2.0;
	angf = pi - angd - ange;
	dsin = sin(angd); esin = sin(ange); fsin = sin(angf);
	AF = c / fsin * esin; AE = b / esin * fsin;
	BD = a / dsin * fsin; BF = c / fsin * dsin;
	CD = a / dsin * esin; CE = b / esin * dsin;
	DE = CD + CE; EF = AE + AF; FD = BD + BF;
	printf("%.2lf ", GetArea(DE, EF, FD));
	rd = GetR(BD, CD, a);
	re = GetR(AE, CE, b);
	rf = GetR(AF, BF, c);
	printf("%.2lf\n", (angd * rd * rd + ange * re * re + angf * rf *rf) / 2.0);
}

int main()
{
	int cas = 1;
	while(scanf("%lf%lf%lf", &a, &b, &c) && (a || b || c))
	{	
		printf("Case %d: ", cas++);
		Calc();
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值