题链:

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. Flask 蓝图(Blueprint)

    蓝图使用起来就像应用当中的子应用一样,可以有自己的模板,静态目录,有自己的视图函数和URL规则,蓝图之间互相不影响.但是它们又属于应用中,可以共享应用的配置.对于大型应用来说,我们可以通过添加蓝图来扩 ...

  2. python 操作SQLAlchemy

    SQLAlchemy python链接 pymysql mysql+pymysql://<username>:<password>@<host>/<dbnam ...

  3. ThreadLocal源码分析:(一)set(T value)方法

    在ThreadLocal的get(),set()的时候都会清除线程ThreadLocalMap里所有key为null的value. 而ThreadLocal的remove()方法会先将Entry中对k ...

  4. 外网访问本地服务器下的web应用

    让本地服务器可以在外网访问的方式有很多,介绍其中一种: 由于本人是在自己电脑上装了一个虚拟机, 测试环境为:虚拟机作为服务器,服务器中装了一个禅道,虚拟机IP192.168.2.221,本人通过tpl ...

  5. Python内置函数(13)——bytearray

    英文文档: class bytearray([source[, encoding[, errors]]]) Return a new array of bytes. The bytearray cla ...

  6. 《深入实践Spring Boot》阅读笔记之二:分布式应用开发

    上篇文章总结了<深入实践Spring Boot>的第一部分,这篇文章介绍第二部分:分布式应用开发,以及怎么构建一个高性能的服务平台. 主要从以下几个方面总结: Spring Boot SS ...

  7. kubernetes入门(07)kubernetes的核心概念(4)

    一.pod 二.Volume volume可以为容器提供持久化存储,比如 三.私有镜像 在使用私有镜像时,需要创建一个docker registry secret,并在容器中引用.创建docker r ...

  8. SpringCloud的EurekaClient : 客户端应用访问注册的微服务(有断路器场景)

    演示客户端应用如何访问注册在EurekaServer里的微服务 一.概念和定义 采用Ribbon或Feign方式访问注册到EurekaServer中的微服务.1.Ribbon实现了客户端负载均衡,2. ...

  9. KNN算法简单应用

    这里是写给小白看的,大牛路过勿喷. 1 KNN算法简介 KNN(K-Nearest Neighbor)工作原理:存在一个样本数据集合,也称为训练样本集,并且样本集中每个数据都存在标签,即我们知道样本集 ...

  10. Python之几种常用模块

    模块 注意事项: 所有的模块导入都应该尽量往上写 内置模块 扩展模块 自定义模块 模块不会重复被导入 : sys.moudles 从哪儿导入模块 : sys.path import import 模块 ...