题链:

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. Java+Maven+selenium+testing+reportNG自动化测试框架

    最近公司新出了一个产品,需要搭建自动化测试框架,这是一个学以至用的好机会,跟上级申请后,决定搭建一个java自动化测试框架. Java自动化测试对我来讲可以说不难不易,因为java是我大学在校四年学的 ...

  2. 网络IO超时的几种实现

    一.select/poll/epoll int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,str ...

  3. redis入门(03)redis的配置

    一.配置文件 Redis 的配置文件位于 Redis 安装目录下,文件名为 redis.conf.你可以通过 CONFIG 命令查看或设置配置项. 二.查看修改 1.查看配置 1.1.vi redis ...

  4. BlueMix - IBM的Paas云计算平台

    Bluemix,2015年年中,IBM推出了名为Bluemix的云计算平台.这一"平台即服务"的PaaS云将帮助开发者更快的进行应用开发和部署.   Bluemix正是IBM回应这 ...

  5. gradle入门(1-4)多项目构建实战

    一.多项目构建 1.多项目构建概念 尽管我们可以仅使用单个组件来创建可工作的应用程序,但有时候更广泛的做法是将应用程序划分为多个更小的模块. 因为这是一个非常普遍的需求,因此每个成熟的构建工具都必须支 ...

  6. EasyUI easyui-combobox实现数据联动

    实现效果:当用户选择了调查地区以后,只显示当前选择地区的频道,如果没有选择地区,那么频道下拉列表是空的.实现效果,如下

  7. Java中对List去重, Stream去重

    问题 当下互联网技术成熟,越来越多的趋向去中心化.分布式.流计算,使得很多以前在数据库侧做的事情放到了Java端.今天有人问道,如果数据库字段没有索引,那么应该如何根据该字段去重?大家都一致认为用Ja ...

  8. 将Tomcat添加进服务启动

    tomcat有解压版和安装版2种版本,安装版已经做好了将tomcat添加进服务的操作,而解压版需要我们自己来实现,应用场景主要是在服务器端需要在服务器启动时就启动tomcat. 1.首先需要配置好jd ...

  9. shell:bash环境

    1.什么是shell shell一般代表两个层面的意思,一个是命令解释器,比如BASH,另外一个是shell脚本. 命令解释器shell的发展史,sh-csh-ksh-tcsh-bash. 2.命令的 ...

  10. Hive:表1inner join表2结果group by优化

    问题背景 最近遇到一个比较棘手的事情:hive sql优化: lib表(id,h,soj,noj,sp,np)         --一个字典表 mitem表(md,mt,soj,noj,sp,np)- ...