【计算几何】求三角形外接圆的周长、面积公式


步骤公式:

  • 已知三角形三边长a、b、c

  • 外接圆半周长: p = a + b + c 2 p = {a + b + c\over2} p=2a+b+c

  • 外接圆面积: S = p ( p − a ) ( p − b ) ( p − c ) S= \sqrt{p(p - a)(p - b) (p - c)} S=p(pa)(pb)(pc)

  • 外接圆直径: d = a b c 2 S d = {abc\over2S} d=2Sabc

  • 外接圆半径: R = a b c 4 S R={abc\over4S} R=4Sabc

  • 外接圆周长: C = 2 π R C=2\pi R C=2πR



例题: HDU 1374 - The Circumference of the Circle

题意: 给出三个点的坐标,求出这三个点所构成三角形的外接圆周长。

思路: 直接套用公式即可。


Code:

#include <iostream>
#include <iomanip>
#include <cmath>
#define pi 3.141592653589793
using namespace std;
int main() {
    double x1,y1,x2,y2,x3,y3;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3) {
        double x = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        double y = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
        double z = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
        double p = (x+y+z)/2.0;
        double s = sqrt(p*(p-x)*(p-y)*(p-z));
        double d = x*y*z/(2.0*s);
        cout<<fixed<<setprecision(2)<<pi*d<<endl;
    }
    return 0;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值