题链:

http://poj.org/problem?id=1329

题解:

计算几何,求过不共线的三点的圆

就是用向量暴力算出来的东西。。。

(设出外心M的坐标,由于$|\vec{MA}|=|\vec{MB}|=|\vec{MC}|$,可以解出M点坐标。)

代码:

#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const double eps=1e-8;
int sign(double x){
if(fabs(x)<=eps) return 0;
return x<0?-1:1;
}
void Pout(double x){//Print_Out
if(sign(x)<0) printf(" - ");
else printf(" + ");
printf("%.3lf",fabs(x));
}
struct Point{
double x,y;
Point(double _x=0,double _y=0):x(_x),y(_y){}
int Read(){return scanf("%lf%lf",&x,&y);}
};
typedef Point Vector;
Vector operator + (Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Point A,Point B){return Vector(A.x-B.x,A.y-B.y);}
double operator ^ (Vector A,Vector B){return A.x*B.y-A.y*B.x;}
double operator * (Vector A,Vector B){return A.x*B.x+A.y*B.y;}
struct Circle{
Point o; double r;
Circle(Point _o=Point(),double _r=0):o(_o),r(_r){}
void PrintSE(){//Print_Standard_Equation
printf("(x");Pout(-o.x);printf(")^2"); printf(" + ");
printf("(y");Pout(-o.y);printf(")^2"); printf(" = ");
printf("%.3lf^2\n",r);
}
void PrintNE(){//Print_Normal_Equation
printf("x^2 + y^2");
Pout(-2*o.x);printf("x");
Pout(-2*o.y);printf("y");
Pout(o.x*o.x+o.y*o.y-r*r);
printf(" = 0\n\n");
}
};
double GL(Vector A){//Get_Length
return sqrt(A*A);
}
Circle GC(Point P1,Point P2,Point P3){//Get_Circle
Vector B=P2-P1,C=P3-P1; Point P0;
P0.x=((B*B)*C.y-(C*C)*B.y)/(2*(B^C))+P1.x;
P0.y=((B*B)*C.x-(C*C)*B.x)/(2*(C^B))+P1.y;
return Circle(P0,GL(P0-P1));
}
int main(){
Point A,B,C;
while(~A.Read()&&~B.Read()&&~C.Read()){
GC(A,B,C).PrintSE();
GC(A,B,C).PrintNE();
}
return 0;
}

  

●POJ 1329 Circle Through Three Points的更多相关文章

  1. POJ - 1329 Circle Through Three Points 求圆

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4112   Acce ...

  2. poj 1329 Circle Through Three Points(求圆心+输出)

    题目链接:http://poj.org/problem?id=1329 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring&g ...

  3. POJ 1329 Circle Through Three Points(三角形外接圆)

    题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...

  4. POJ 1329 Circle Through Three Points(三角形外心)

    题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...

  5. poj1329 Circle Through Three Points

    地址:http://poj.org/problem?id=1329 题目: Circle Through Three Points Time Limit: 1000MS   Memory Limit: ...

  6. POJ 1329 三角外接圆

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3169   Acce ...

  7. poj 1329(已知三点求外接圆方程.)

    Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3766   Acce ...

  8. poj 1981 Circle and Points

    Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8131   Accepted: 2899 ...

  9. POJ 1981 Circle and Points (扫描线)

    [题目链接] http://poj.org/problem?id=1981 [题目大意] 给出平面上一些点,问一个半径为1的圆最多可以覆盖几个点 [题解] 我们对于每个点画半径为1的圆,那么在两圆交弧 ...

随机推荐

  1. 1013团队Beta冲刺day1

    项目进展 李明皇 今天解决的进度 点击首页list相应条目将信息传到详情页 明天安排 优化信息详情页布局 林翔 今天解决的进度 前后端连接成功 明天安排 开始微信前端+数据库写入 孙敏铭 今天解决的进 ...

  2. 用python实现简单购物车功能

    all_asset = 0 i1 = input("请输入总资产:") all_asset = int(i1) goods = [ {'name':'电脑','price':199 ...

  3. css3动画transition详解

    一.transition-property 语法: transition-property : none | all | [ <IDENT> ] [ ',' <IDENT> ] ...

  4. python小练习之二

    title: python小练习之二 tags: 新建,模板,小书匠 grammar_cjkRuby: true --- python小练习之二 需求:实现用户登录,用户名和密码保存到文件里,连续输入 ...

  5. LeetCode & Q121-Best Time to Buy and Sell Stock-Easy

    Array DP Description: Say you have an array for which the ith element is the price of a given stock ...

  6. 第三章 JavaScript操作BOM对象

    第三章   JavaScript操作BOM对象 一.window对象 浏览器对象模型(BOM)是javascript的组成之一,它提供了独立与浏览器窗口进行交换的对象,使用浏览器对象模型可以实现与HT ...

  7. python pickle 模块的使用

    用于序列化的两个模块 json:用于字符串和Python数据类型间进行转换 pickle: 用于python特有的类型和python的数据类型间进行转换 json提供四个功能:dumps,dump,l ...

  8. copy代码(含static对象)留下的致命错误

    本来以为这个bug快改不好了,然而发现了问题所在 copy代码没有完全改掉对象名称,导致对象重复创建了,由于是static所以debug过程中 注释了addProperty(gridRowDetail ...

  9. CSS优先级和定位

    overflow属性 hidden scroll auto hidden 超出隐藏 scroll 滚动条 Auto 自动 display属性 block inline inline-block non ...

  10. String、StringBuffer、StringBulider之间的联系和区别

    首先,我们大概总体的解释一下这三者的区别和联系 String的值是不可变的,这就导致每次对String的操作都会生成新的String对象,不仅效率低下,而且大量浪费有限的内存空间. StringBuf ...