模版题,求三点定圆,求三角行的外心
数学都记不得了,,
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
struct point
{
double x,y;
point() {}
point(double a,double b):x(a),y(b) {}
};
point CircumCenter(point a,point b,point c)
{
point cp;
double a1=b.x-a.x,b1=b.y-a.y,c1=(a1*a1+b1*b1)/2;
double a2=c.x-a.x,b2=c.y-a.y,c2=(a2*a2+b2*b2)/2;
double d=a1*b2-a2*b1;
cp.x=a.x+(c1*b2-c2*b1)/d;
cp.y=a.y+(a1*c2-a2*c1)/d;
return cp;
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
point a,b,c;
while(scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)!=EOF){
point cp=CircumCenter(a,b,c);
double r=sqrt(pow(cp.x-a.x,2.0)+pow(cp.y-a.y,2.0));
printf("%.2f\n",2*r*PI);
}
return 0;
}