poj1329 Circle Through Three Points 三角形外接圆(水)
来源:互联网 发布:日系男装店 知乎 编辑:程序博客网 时间:2024/05/01 21:37
题目链接:http://poj.org/problem?id=1329
给出三个点,求外接圆的两种表达式:
//代码如下:
#include<iostream>#include<cstdio>#include<math.h>#define eps 1e-8struct point{double x,y;};point a,b,c;double distance(point p1,point p2){ return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));}point intersection(point p1,point p2,point p3,point p4){ point ret=p1; double t=((p1.x-p3.x)*(p3.y-p4.y)-(p1.y-p3.y)*(p3.x-p4.x)) /((p1.x-p2.x)*(p3.y-p4.y)-(p1.y-p2.y)*(p3.x-p4.x)); ret.x+=(p2.x-p1.x)*t; ret.y+=(p2.y-p1.y)*t; return ret;}point circenter(point a,point b,point c)//Èý½ÇÐÎÍâ½ÓÔ²ÐÄ{ point p1,p2,p3,p4; p1.x=(a.x+b.x)/2.0; p1.y=(a.y+b.y)/2.0; p2.x=p1.x-(b.y-a.y); p2.y=p1.y+(b.x-a.x); p3.x=(a.x+c.x)/2.0; p3.y=(a.y+c.y)/2.0; p4.x=p3.x-(c.y-a.y); p4.y=p3.y+(c.x-a.x); return intersection(p1,p2,p3,p4);}int main(){ while(~scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)) { point cen=circenter(a,b,c); double dis=distance(cen,a); printf("(x %c %.3lf)^2 + (y %c %.3lf)^2 = %.3lf^2\n",(cen.x>=0 ?'-':'+'),fabs(cen.x),(cen.y>=0 ?'-':'+'),fabs(cen.y),dis); printf("x^2 + y^2 %c %.3lfx %c %.3lfy %c %.3lf = 0\n", (cen.x>=0 ?'-':'+'), 2*fabs(cen.x), (cen.y>=0 ?'-':'+'),2*fabs(cen.y),(cen.x*cen.x+cen.y*cen.y-dis*dis>=0 ? '+':'-'),fabs(cen.x*cen.x+cen.y*cen.y-dis*dis)); printf("\n"); } return 0;}
- poj1329 Circle Through Three Points 三角形外接圆(水)
- poj1329 Circle Through Three Points
- POJ1329-Circle Through Three Points
- POJ1329 Circle Through Three Points(解析几何,圆)
- poj 1329 Circle Through Three Points(求三角形外接圆)
- POJ 1329 Circle Through Three Points 求三角形外接圆
- POJ 1329 Circle Through Three Points(求三角形的外接圆)
- (计算几何8.1.2.3)POJ 1329 Circle Through Three Points(利用叉积来计算三角形的外接圆的圆心)
- Circle Through Three Points
- poj1329Circle Through Three Points【求三角形外接圆圆心】
- poj 1329 Circle Through Three Points
- poj 1329 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- UVa 190 - Circle Through Three Points
- uva 190 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- POJ 1329 Circle Through Three Points
- poj 1375 Intervals 圆的切线
- How to Completely Fix Runtime Error 216 Error
- 简单c/c++笔试题 .
- 1196. History Exam
- mvc3 提供程序未返回 ProviderManifestToken 字符串
- poj1329 Circle Through Three Points 三角形外接圆(水)
- MFC与wxWidgets比较
- 一个程序员的艰辛路程(成功需要汗水和磨练)
- 由字符串是否包含想到的字符串的排序
- [Basic]面向对象之信息隐藏(二)
- 移动产品设计之ios导航模式
- truelicense简要说明
- 各种排序算法_python
- oracle flashback