这些代码未经过题目测试,存在安全隐患。。。。
struct circle
{
Point p;
double r;
circle(){
}
circle(Point pp,double rr)
{
p=pp,r=rr;
}
circle(double xx,double yy,double rr)
{
p=Point(xx,yy);
r=rr;
}
//三角形外接圆
//利用两条边的中垂线得到圆心
circle(Point a,Point b,Point c)
{
Line u=Line((a+b)/2,((a+b)/2)+((b-a).turn_left()));
Line v=Line((b+c)/2,((b+c)/2)+((c-b).turn_left()));
p=u.cross_point(v);
r=p.dis(a);
}
//三角形内切圆,bool t只是为了重载
circle(Point a,Point b,Point c,bool t)
{
Line u,v;
double m=atan2(b.y-a.y,b.x-a.x),n=atan2(c.y-a.y,c.x-a.x);
u.s=a;
u.e=u.s+Point(cos((n+m)/2),sin((n+m)/2));
m=atan2(a.y-b.y,a.x-b.x),n=atan2(c.y-b.y,c.x-b.x);
v.s=b;
v.e=v.s+Point(cos((n+m)/2),sin((n+m)/2));
p=u.cross_point(v);
r=Line(a,b).dis_point_to_seg(p);
}
void input(void)
{
p.input();
scanf("%lf",&r);
}
void output(void)
{
printf("%.2f %.2f %.2f\n",p.x,p.y,r);
}
bool operator == (const circle &v)
{
return (p==v.p)&&sgn(r-v.r)==0;
}
bool operator <(const circle &v) const
{
return ((p<v.p)||((p==v.p)&&sgn(r-v.r)<0));
}
double area(void)
{
return pi*r*r;
}
double cir(void)
{
return 2*pi*r;
}
//点和圆的关系,
//0 圆外
//1 圆上
//2 圆内
int rel_of_point(