poj1329Circle Through Three Points(三角形外接圆)
套模板
不知道有没有x,y=0情况,不过这种情况都按+号输出的。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct Point
{
double x,y;
Point (double x=,double y =):x(x),y(y){}
}p[];
struct Circle
{
Point center;
double r;
};
typedef Point pointt;
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
double dis(Point a)
{
return a.x*a.x+a.y*a.y;
}
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
double area()
{
return fabs(cross(p[]-p[],p[]-p[]))/;
}
struct Circle Circumcircle()
{
Circle tmp;
double a,b,c,c1,c2;
double xa,ya,xb,yb,xc,yc;
a = sqrt(dis(p[]-p[]));
b = sqrt(dis(p[]-p[]));
c = sqrt(dis(p[]-p[]));
//根据s = a*b*c/R/4,求半径
tmp.r = (a*b*c)/(area()*4.0);
xa = p[].x;
ya = p[].y;
xb = p[].x;
yb = p[].y;
xc = p[].x;
yc = p[].y;
c1 = (dis(p[])-dis(p[]))/;
c2 = (dis(p[])-dis(p[]))/;
tmp.center.x = (c1*(ya-yc)-c2*(ya-yb))/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb));
tmp.center.y = (c1*(xa-xc)-c2*(xa-xb))/((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb));
return tmp;
}
int main()
{
while(scanf("%lf%lf%lf%lf%lf%lf",&p[].x,&p[].y,&p[].x,&p[].y,&p[].x,&p[].y)!=EOF)
{
Circle cc = Circumcircle();
double r = cc.r;
char c1,c2;
c1 = dcmp(cc.center.x)>?'-':'+';
c2 = dcmp(cc.center.y)>?'-':'+';
printf("(x %c %.3f)^2 + (y %c %.3f)^2 = %.3f^2\n",c1,fabs(cc.center.x),c2,fabs(cc.center.y),r);
double s = r*r-cc.center.x*cc.center.x-cc.center.y*cc.center.y;
char c3 = dcmp(s)>?'-':'+';
printf("x^2 + y^2 %c %.3fx %c %.3fy %c %.3f = 0\n",c1,fabs(cc.center.x*),c2,fabs(cc.center.y*),c3,fabs(s));
puts("");
}
return ;
}
poj1329Circle Through Three Points(三角形外接圆)的更多相关文章
- POJ 1329 Circle Through Three Points(三角形外接圆)
题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorit ...
- poj1266Cover an Arc(三角形外接圆)
链接 求出三角形的外接圆,通过圆心和半径可以知道这个圆的上下左右最远点,分别判断这个四个点跟弧的两端点A,B的关系,假如判断P点,弧内给出点为C,判断PC是否与AB相交即可判断出P是否在弧上. 精度问 ...
- HDU4720+三角形外接圆
/* 几何 求给定三角形的外接圆圆心 方法:求解二元方程组 */ #include<stdio.h> #include<string.h> #include<math.h ...
- matlab练习程序(三角形外接圆)
三角形两边的垂直平分线就能确定外接圆. 结果如下: matlab代码如下: clear all;close all;clc; p=rand(,); %(x,y) cen1=(p(,:)+p(,:))/ ...
- POJ 1329 Circle Through Three Points(三角形外心)
题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...
- 算法笔记_082:蓝桥杯练习 12-1三角形(Java)
目录 1 问题描述 2 解决方案 1 问题描述 问题描述 为二维空间中的点设计一个结构体,在此基础上为三角形设计一个结构体.分别设计独立的函数计算三角形的周长.面积.中心和重心.输入三个点,输出这 ...
- [转] POJ计算几何
转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板 ...
- ACM计算几何题目推荐
//第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...
- UVA12304 2D Geometry 110 in 1! 计算几何
计算几何: 堆几何模版就能够了. . .. Description Problem E 2D Geometry 110 in 1! This is a collection of 110 (in bi ...
随机推荐
- mysql 段错误 (core dumped)
一直使用好好的mysql命令,突然今天抽风,无论使用任何mysql选项都报“段错误 (core dumped)”,以为是mysqld程序出问题了,所以我尝试重启,因为我的环境上是多实例,用了mysql ...
- c#之财务系统数据库
财务收费系统补充数据库表 1. 学生表(F_Student) 名称 代码 数据类型 强制性的 ID s_ID int TRUE 学生姓名 Stu_name varchar (50) TRUE 身份证 ...
- Java学习之路(二)
什么是变量? 1:计算机是一种嫉妒精确的机器 2:要将信息存储在计算机当中,就必须指明信息存储的位置和所需的内存空间: 3:在Java当中 使用声明语句来完成上述任务 变量的类型:
- corefile的设置与使用
一.简介 corefile是Linux下程序崩溃时生成的文件,可以用来分析程序崩溃的原因,因为它内部包含了程序崩溃时的堆栈信息. 二.corefile的设置 默认情况下,程序崩溃是不会生成corefi ...
- Codeforces Round #260 (Div. 2) C
Description Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. On ...
- php获取前一天后一天,php时间函数操作
<?php date_default_timezone_set('PRC'); //默认时区 echo "今天:",date("Y-m-d",time() ...
- shell脚本之lnmp的搭建
!/bin/bash #this script is source packages installed lnmp .xmal yum -y install wget #"========= ...
- CentOS6.5下安装wine OK
这篇文章主要记录了如何在CentOS 6.5上安装Wine 1.7.24开发版 1.安装需要的软件包 # yum groupinstall ‘Development Tools‘ # yum inst ...
- SqlSever基础 rtrim函数 除去字符串的右边的空格,左边中间的不管
镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...
- 《微信开发日志》之OAuth2验证接口
OAuth2接口说明: 企业应用中的URL链接(包括自定义菜单或者消息中的链接),可以通过OAuth2.0验证接口来获取员工的身份信息. 通过此接口获取用户身份会有一定的时间开销.对于频繁获取用户身份 ...