计算几何专题(计算两圆相交面积)
来源:互联网 发布:win10 linux bash 编辑:程序博客网 时间:2024/05/22 09:49
There are two circles in the plane (shown in the below picture), there is a common area between the two circles. The problem is easy that you just tell me the common area. Input
There are many cases. In each case, there are two lines. Each line has three numbers: the coordinates (X and Y) of the centre of a circle, and the radius of the circle.
Output
For each case, you just print the common area which is rounded to three digits after the decimal point. For more details, just look at the sample.
Sample Input
0 0 2
2 2 1
Sample Output
There are many cases. In each case, there are two lines. Each line has three numbers: the coordinates (X and Y) of the centre of a circle, and the radius of the circle.
Output
For each case, you just print the common area which is rounded to three digits after the decimal point. For more details, just look at the sample.
Sample Input
0 0 2
2 2 1
Sample Output
0.108
#include<cstdio>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>using namespace std;#define PI acos(-1.0)int main(){ double a1,b1,r1,a2,b2,r2,d; double A1,A2,s1,s2,s; while(~scanf("%lf%lf%lf%lf%lf%lf",&a1,&b1,&r1,&a2,&b2,&r2)){ d=sqrt((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1)); //求圆心距 if(d>=r1+r2) printf("0.000\n"); //两圆相离或相外切 else if(d<=fabs(r1-r2) && d>=0) { //内切 if(r1>r2) printf("%0.3lf\n",PI*r2*r2); else printf("%0.3lf\n",PI*r1*r1); } else { A1=2*acos((d*d+r1*r1-r2*r2)/(2*d*r1)); //求以圆心为顶点与两圆交点连线的角 A2=2*acos((d*d+r2*r2-r1*r1)/(2*d*r2)); s1=0.5*r1*r1*sin(A1)+0.5*r2*r2*sin(A2); s2=A1/2*r1*r1+A2/2*r2*r2; s=s2-s1; printf("%0.3lf\n",s); } } return 0;}
阅读全文
0 0
- 计算几何专题(计算两圆相交面积)
- 计算几何:两圆相交面积
- 计算两圆相交面积
- 两圆相交面积计算
- POJ 2546 Circular Area(计算几何 两圆相交面积)
- POJ 2546 Circular Area【计算几何,计算两圆相交面积】
- 计算几何 求相交圆面积(余弦定理)
- hdoj.5120 Intersection【计算几何-两圆相交面积】 2015/08/01
- Tell me the area(计算几何--求两圆相交面积)
- HDU 3264 Open-air shopping malls (计算几何-圆相交面积)
- HDU 1798 Tell me the area(计算几何,求相交圆面积)
- hdoj Intersection 5120 (数学计算几何) 求两个相交圆的面积
- 计算几何-判断两线段是否相交(模板)
- 计算几何,判两线段相交模板
- 计算几何之两线段相交
- 计算几何----判断两矩形是否相交
- 几何 两元相交的面积计算问题 HDU 5120 Intersection(几何模板)
- HDU 3264 Open-air shopping malls (计算两圆相交的面积 + 二分)
- XYNUOJ 1246: Repair the Wall 贪心水题 酒馆浪人的博客
- 【单调栈】acm题目
- python查询mysql导出结果至Excel并发送邮件
- 前端window.onerror()的用法
- python学习——Python 数字(Number)
- 计算几何专题(计算两圆相交面积)
- unix下的DOS命令
- 如何画全局优化问题的收敛曲线和多目标优化的Pareto前沿(使用gaoptimset函数)
- Android build.gradle
- 从零开始部署Node.js服务至阿里云ECS服务器并实现外网IP访问
- 用Mendeley在Word插入参考文献
- 有没有职业规划的30岁,可以差出多少万年薪?
- idea 下载、上传项目到github
- Python 学习笔记: A byte of python (一) 基础