HDU1798 简单高中的计算几何题= =。正余弦定理的综合应用么。。。
来源:互联网 发布:dreamweaver有mac版吗 编辑:程序博客网 时间:2024/04/29 07:18
Tell me the area
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1629 Accepted Submission(s): 490
Problem Description
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 22 2 1
Sample Output
0.108题意:给你两圆坐标和各自的半径,求公共部分面积。思路:分析两圆关系先:1.外切或相离面积为0 2.内含或内切面积为小圆面积。 3.相交:A.相交弦在圆心之间 B.相交弦在圆心一侧:后面发现算面积的时候不会有影响。 4.一开始没注意的:两圆可能半径为0.....略坑。。。 相交做法:S=S扇形1+S扇形2-S三角形1-S三角形2,具体可以自己画图。。。高中应该做过类似的解析几何题。。。注意:后面还WA了一次是因为PI的精度不够,后来换上了官方PI的写法A了- -|||。。。上代码。。。#include<cstdio>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>//#define PI 3.1415926using namespace std;int main(){ double x1,y1,r1; double x2,y2,r2; double dis; double s; double a1,a2; double s1,s2,ss1,ss2; double PI=2*asin(1.0); //printf("%.10lf\n",PI); while(cin>>x1>>y1>>r1) { cin>>x2>>y2>>r2; dis=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if(dis>=r1+r2||r1==0||r2==0)//两圆外切或相离或有圆的半径为0 s=0; else if(dis<=abs(r1-r2))//两圆内含或者内切 { if(r1>r2) r1=r2; s=PI*r1*r1; } else { a1=acos((dis*dis+r1*r1-r2*r2)/(2*dis*r1));//在圆O1内的圆心角一半 a2=acos((dis*dis+r2*r2-r1*r1)/(2*dis*r2));//在圆O2内的圆心角一半 s1=r1*r1*sin(a1)*cos(a1);//正弦定理(r1*r1*sin2a2)/2的化简 s2=r2*r2*sin(a2)*cos(a2);//同上 ss1=r1*r1*a1;//第一个扇形的面积。 ss2=r2*r2*a2;//第二个扇形的面积 s=ss1+ss2-s1-s2;//两个扇形的面积之和减去两个三角形的面积。 } printf("%.3lf\n",s); } return 0;}
0 0
- HDU1798 简单高中的计算几何题= =。正余弦定理的综合应用么。。。
- pick定理的应用——简单的计算几何问题Triangle
- 余弦定理的应用:基于文字的文本相似度计算
- 正余弦定理
- 正余弦定理公式
- 计算几何 求相交圆面积(余弦定理)
- [转]使用余弦定理计算两篇文章的相似性
- 使用余弦定理计算两篇文章的相似性
- 使用余弦定理计算两篇文章的相似性
- C#画正余弦函数图像的简单例子
- QWT学习——绘制简单的正余弦曲线
- timus 1294. Mars Satellites 余弦定理的应用
- 兴趣学习: 余弦定理的应用&nb…
- 余弦定理的三个证明
- 余弦定理----相似性计算
- 计算几何的基本应用~~~~
- poj1269 简单的计算几何
- 计算几何 欧拉定理应用
- Java集合框架基础
- 剑指XX游戏(七) - 不拼搏,枉少年
- 编译型语言vs解释型语言
- 广告反作弊相关技术
- 电脑必装软件列表整理,必属精品
- HDU1798 简单高中的计算几何题= =。正余弦定理的综合应用么。。。
- thinkpad x61 无线网卡驱动 debian 7 下配置 安装
- 0.driverbase-字符串、文件、注册表相关函数
- 全表扫描
- PHP新手开发必会碰到的问题
- 设计模式学习: 工厂模式
- window快捷键
- 极大极小过程 UVA 10838 - The Pawn Chess
- Python中字符串的总结