计算几何(三角形外接圆) - The Circumference of the Circle - UVA 438

计算几何(三角形外接圆) - The Circumference of the Circle - UVA 438

题意:

给 定 三 个 不 共 线 的 点 的 坐 标 , 输 出 外 接 圆 的 周 长 。 给定三个不共线的点的坐标,输出外接圆的周长。 线

输入:

多 组 测 试 数 据 , 多组测试数据,

每 组 依 次 包 括 三 个 顶 点 的 横 纵 坐 标 。 每组依次包括三个顶点的横纵坐标。

输出:

一 个 浮 点 数 , 表 示 周 长 , 小 数 点 后 保 留 两 位 数 字 。 一个浮点数,表示周长,小数点后保留两位数字。


代码:

#define _CRT_SECURE_NO_WARNINGS

#include<cstring>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;

const double eps = 1e-10;
const double pi = acos(-1.0);

struct Point 
{
    double x,y;
    Point(double x = 0, double y = 0):x(x),y(y){}
};

Point Excenter(Point a, Point b, Point c)
{
    double a1 = b.x - a.x;
    double b1 = b.y - a.y;
    double c1 = (a1*a1 + b1*b1)/2;
    double a2 = c.x - a.x;
    double b2 = c.y - a.y;
    double c2 = (a2*a2 + b2*b2)/2;
    double d = a1*b2 - a2*b1;
    return Point(a.x + (c1*b2 - c2*b1)/d, a.y + (a1*c2 - a2*c1)/d);
}

double dis(Point a,Point b)
{
    double dx=a.x-b.x, dy=a.y-b.y;
    return sqrt(dx*dx+dy*dy);
}

int main()
{
    Point A,B,C;
    while(~scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y))
    {
        Point O=Excenter(A,B,C);
        double r=dis(O,A);
        printf("%.2lf\n",2.0*pi*r);
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值