●POJ 1329 Circle Through Three Points
题链:
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的更多相关文章
- POJ - 1329 Circle Through Three Points 求圆
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4112 Acce ...
- poj 1329 Circle Through Three Points(求圆心+输出)
题目链接:http://poj.org/problem?id=1329 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring&g ...
- POJ 1329 Circle Through Three Points(三角形外接圆)
题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...
- POJ 1329 Circle Through Three Points(三角形外心)
题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...
- poj1329 Circle Through Three Points
地址:http://poj.org/problem?id=1329 题目: Circle Through Three Points Time Limit: 1000MS Memory Limit: ...
- POJ 1329
三角外接圆
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3169 Acce ...
- poj 1329(已知三点求外接圆方程.)
Circle Through Three Points Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3766 Acce ...
- poj 1981 Circle and Points
Circle and Points Time Limit: 5000MS Memory Limit: 30000K Total Submissions: 8131 Accepted: 2899 ...
- POJ 1981 Circle and Points (扫描线)
[题目链接] http://poj.org/problem?id=1981 [题目大意] 给出平面上一些点,问一个半径为1的圆最多可以覆盖几个点 [题解] 我们对于每个点画半径为1的圆,那么在两圆交弧 ...
随机推荐
- 高级软件工程2017第7次作业--C++团队项目:Beta阶段综合报告
1.Beta阶段敏捷冲刺每日报告 Bate版敏捷冲刺报告--day0 Bate版敏捷冲刺每日报告--day1 Bate敏捷冲刺每日报告--day2 Bate敏捷冲刺每日报告--day3 Bate敏捷冲 ...
- 201621123050 《Java程序设计》第3周学习总结
1. 本周学习总结 初学面向对象,会学习到很多碎片化的概念与知识.尝试学会使用思维导图将这些碎片化的概念.知识点组织起来.请使用工具画出本周学习到的知识点及知识点之间的联系.步骤如下: 1.1 写出你 ...
- QTableView
QTableView常用于实现数据的表格显示.下面我们如何按步骤实现学生信息表格: 一 添加表头 //准备数据模型 QStandardItemModel *student_model = ne ...
- Android实验报告
实验名称:Android程序设计 实验时间:2017.5.24 实验人员:20162309邢天岳(结对同学20162313苑洪铭) 实验目的:使用android stuidio开发工具进行基本安卓软件 ...
- Huginn实现自动通过slack推送豆瓣高分电影
博客搬迁至https://blog.wangjiegulu.com RSS订阅:https://blog.wangjiegulu.com/feed.xml 原文链接:https://blog.wang ...
- JavaScript查找数组中最大的值
// 查找一个数组中最大的数 // 定义一个方法 searchMax function searchMax(arr) { // 声明一个变量MaxNumber假设为数组中最大的值arr[0]; var ...
- jenkins 简单实现php集成上线部署
基于公司git版本控制,搭建jenkins实现php集成部署(没有用gitlab,测试服配置较低,gitlab卡的不要不要的了-) 一.安装jenkins相关依赖 wget -O /etc/yum.r ...
- 新概念英语(1-105)Full Of Mistakes
Lesson 105 Full of mistakes 错误百出 Listen to the tape then answer this question. What was Sandra's pre ...
- SpringCloud的DataRest(三)
一.进阶配置定义 二.定制显示内容和控制方法使用 1.控制显示的内容 如果想让输出显示的数据始终按我们定义的格式显示: 配置之后返回的JSON数据会按照ListApp定义的数据格式进行输出 2.屏蔽自 ...
- CURL学习总结(1)
1.curl是什么? 百度百科定义: curl是利用URL语法在命令行方式下工作的开源文件传输工具.它被广泛应用在Unix.多种Linux发行版中,并且有DOS和Win32.W ...