bnuoj 4209 Triangle(计算几何)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4209
题意:如题
题解:公式直接计算,或者角平分线求交点
【code1】:
#include <iostream>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include<stdio.h> using namespace std;
//定义点
struct point
{
double x,y;
}; typedef struct point point; double fabs(double x)
{
return x<?-x:x;
}
//定义直线
struct line
{
point a,b;
};
typedef struct line line; //两点距离
double distance(point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
//两直线求交点
point intersection(line u,line v)
{
point ret=u.a;
double t=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))
/((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x));
ret.x+=(u.b.x-u.a.x)*t;
ret.y+=(u.b.y-u.a.y)*t;
return ret;
} point incenter(point a,point b,point c)
{
line u,v;
double m,n;
u.a=a;
m=atan2(b.y-a.y,b.x-a.x);
n=atan2(c.y-a.y,c.x-a.x);
u.b.x=u.a.x+cos((m+n)/);
u.b.y=u.a.y+sin((m+n)/);
v.a=b;
m=atan2(a.y-b.y,a.x-b.x);
n=atan2(c.y-b.y,c.x-b.x);
v.b.x=v.a.x+cos((m+n)/);
v.b.y=v.a.y+sin((m+n)/);
return intersection(u,v);
} int main()
{
point a,b,c;
scanf("%lf%lf",&a.x,&a.y);
scanf("%lf%lf",&b.x,&b.y);
scanf("%lf%lf",&c.x,&c.y);
point d;
d = incenter(a,b,c);
if(fabs(d.x)<1e-) d.x=;
if(fabs(d.y)<1e-) d.y=;
printf("%.2lf %.2lf\n",d.x,d.y);
return ;
}
【code2】:
#include <iostream>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include<stdio.h> //using namespace std;
//定义点
struct point
{
double x,y;
}; double distance(point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
} int main()
{
point a,b,c;
scanf("%lf%lf",&a.x,&a.y);
scanf("%lf%lf",&b.x,&b.y);
scanf("%lf%lf",&c.x,&c.y);
point d;
double ab = distance(a,b);
double bc = distance(b,c);
double ac = distance(a,c);
d.x = (a.x*bc+b.x*ac+c.x*ab)/(ab+bc+ac);
d.y = (a.y*bc+b.y*ac+c.y*ab)/(ab+bc+ac);
printf("%.2lf %.2lf\n",d.x,d.y);
return ;
}
bnuoj 4209 Triangle(计算几何)的更多相关文章
- hdu 1451 Area in Triangle(计算几何 三角形)
Given a triangle field and a rope of a certain length (Figure-1), you are required to use the rope t ...
- 2018 ICPC Asia Singapore Regional A. Largest Triangle (计算几何)
题目链接:Kattis - largesttriangle Description Given \(N\) points on a \(2\)-dimensional space, determine ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)
Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...
- 湖南程序设计竞赛赛题总结 XTU 1237 Magic Triangle(计算几何)
这个月月初我们一行三人去湖南参加了ccpc湖南程序设计比赛,虽然路途遥远,六月的湘潭天气燥热,不过在一起的努力之下,拿到了一块铜牌,也算没空手而归啦.不过通过比赛,还是发现我们的差距,希望这几个月自己 ...
- bnuoj 1053 EASY Problem (计算几何)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=1053 [题意]:基本上就是求直线与圆的交点坐标 [题解]:这种题我都比较喜欢用二分,三分做,果然可以 ...
- bnuoj 27874 "Center" of [p]erimeter midpoints(计算几何)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=27874 [题意]: 给你一个三角形三个顶点的坐标ABC,三角形各边取一点DEF,将三角形周长平均分割 ...
- POJ 1927 Area in Triangle(计算几何)
Area in Triangle 博客原文地址:http://blog.csdn.net/xuechelingxiao/article/details/40707691 题目大意: 给你一个三角形的三 ...
- 【计算几何】【极角序】【二分】bzoj1914 [Usaco2010 OPen]Triangle Counting 数三角形
极角排序后枚举每个点,计算其与原点连线的左侧的半平面内的点与其组成的三角形数(二分/尺取),这些都不是黄金三角形. 补集转化,用平面内所有三角形的个数(C(n,3))减去这些即可. 精度很宽松,几乎不 ...
随机推荐
- PHP插件技术-插件钩子(hooks)分析
最近准备做一个开源的个人博客系统,因为在构想中要添加插件功能,所以就研究了一下插件功能的实现方法. 插件的功能按照本人自己的理解就是对已有的程序进行功能方面的添加以及改进,插件要与程序所提供的接口进行 ...
- 浅谈.NET Micro Framework性能优化 转自 软件中国
.NET Micro Framework的可剪裁性,高定执行,和天生对硬件高集成度都让它的前途一片光明.当然,它现在还很年轻,就发布的SDK v3.0来看,它还有很长的路要走. 废话不说,就这几个月我 ...
- 更改Activity亮度
有些需求需进入到页面后更改Activity的亮度,退出页面后恢复到之前的亮度.通过更改WindowManager.LayoutParams的screenBrightness可以达到这个效果.scree ...
- SQL Server 添加登录账户配置权限
一.新建登录名 1. 在登录名右侧的文本框中输入新建的管理员账号名称:2. 一对单选按钮组中,选择Sql Server 身份验证,并输入登录密码:3. 勾选强制实施密码策略复选框:(密码策略一般是指加 ...
- 通过SQL ID查询SQL Text
SELECT SQL_ID, SQL_TEXT,FIRST_LOAD_TIME, EXECUTIONS FROM V$SQLAREA where SQL_ID='22v8fyk0juw25';
- iOS-画板的实现
先上一张效果图,有看下去的动力 再来一张工程图片 好,首先是对线的实体的封装,在LineEntity.h文件中创建一个点的数组 然后在LineEntity.m文件中,在初始化方法中给points变量开 ...
- iOS 中对各种视图的截屏以及分享
1.一个第三方的工具,主要是对表视图.滚动视图.视图的扩展,用法也很简单 image = [tableview screenshot]; 2.然后将截的图片分享出去,在分享的时候,因为多个地方用到了截 ...
- 开始写自己的iOS技术博客了
2015-09-26 中秋节前夕,开始写自己的iOS开发相关的技术博客,还请广大专业的人士批评指教!欢迎纠错和交流! 在来到北京的第二家公司艾亿新融资本管理的子公司——资配易.由于基本没有加班,也算有 ...
- C++11智能指针
今晚跟同学谈了一下智能指针,突然想要看一下C++11的智能指针的实现,因此下了这篇博文. 以下代码出自于VS2012 <memory> template<class _Ty> ...
- 《Apache数据传输加密、证书的制作》——涉及HTTPS协议
首先了解http和https: HTTPS(Secure Hypertext Transfer Protocol)安全超文本传输协议. HTTPS和HTTP的区别: http是超文本传输协议,信息是明 ...