Light oj 1433 - Minimum Arc Distance【计算几何(坑精度!)】
来源:互联网 发布:网络游戏同步算法 编辑:程序博客网 时间:2024/06/16 03:59
![](http://lightoj.com/images/submit3.png)
![](http://lightoj.com/images/udebug.png)
You all probably know how to calculate the distance between two points in two dimensional cartesian plane. But in this problem you have to find the minimum arc distance between two points and they are on a circle centered at another point.
You will be given the co-ordinates of the points A and B and co-ordinate of the center O. You just have to calculate the minimum arc distance between A and B. In the picture, you have to calculate the length of arc ACB. You can assume that A and B will always be on the circle centered at O.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing six integers Ox, Oy, Ax, Ay, Bx, By where (Ox, Oy) indicates the co-ordinate of O, (Ax, Ay) denote the co-ordinate of A and (Bx, By) denote the co-ordinate of B. All the integers will lie in the range [1, 10000].
Output
For each case, print the case number and the minimum arc distance. Errors less than 10-3 will be ignored.
Sample Input
Output for Sample Input
5
5711 3044 477 2186 3257 7746
3233 31 3336 1489 1775 134
453 4480 1137 6678 2395 5716
8757 2995 4807 8660 2294 5429
4439 4272 1366 8741 6820 9145
Case 1: 6641.81699183
Case 2: 2295.92880
Case 3: 1616.690325
Case 4: 4155.64159340
Case 5: 5732.01250253
题意:
给出圆的圆心和圆上两点坐标,求两点间间的劣弧长
题解:
题目很简单,基础的计算几何,但是在求的时候,要尽量减少浮点的运算次数,否则会wa,精度比较坑.....
刚开始用acos,错了,换个思路,减少了浮点数运算,用asin AC了......(也可能是之前的程序本身写的有问题)
/*http://blog.csdn.net/liuke19950717*/#include<cstdio>#include<cstring>#include<cmath>const double pi=acos(-1.0);struct point{int x,y;};double dis(point a,point b){return sqrt((a.x-b.x)*(a.x-b.x)*1.0+(a.y-b.y)*(a.y-b.y));}int main(){int t;scanf("%d",&t);for(int k=1;k<=t;++k){point p[3];for(int i=0;i<3;++i){scanf("%d%d",&p[i].x,&p[i].y);}double r=dis(p[0],p[1]),d=dis(p[1],p[2])/2.0;double ans=2*asin(d/r)*r;printf("Case %d: %.8lf\n",k,ans);}return 0;}
- Light oj 1433 - Minimum Arc Distance【计算几何(坑精度!)】
- LightOJ 1433-Minimum Arc Distance【几何】
- LightOJ - 1433 Minimum Arc Distance (数学几何)求圆上两点间的弧长
- LightOJ 1433 Minimum Arc Distance
- LightOJ 1433 - Minimum Arc Distance
- uestc oj Justice is Given by Light(计算几何)
- light oj 1211 - Intersection of Cubes (计算几何)
- 【Light-oj】-Expanding Rods(二分&几何)
- light oj 1043 - Triangle Partitioning【简单计算几何】
- light oj 1216 - Juice in the Glass (几何计算)
- Lightoj1433——Minimum Arc Distance (求弧长)
- UVA - 11796 - Dog Distance (计算几何~)
- 计算几何中的精度问题(转)
- 计算几何中的精度问题 (转)
- 计算几何中的精度问题(转)
- 计算几何中的精度问题(转)
- 计算几何中的精度问题(转)
- 计算几何中的精度问题(转)
- 御道学院-初音喊你去上班!Unity MMD游戏开发教程第1话003节 同人游戏开发教程系列
- MySql中数据库存储过程与触发器案例
- 小米笔试题-右移k位数组元素查找
- UVA 10891 Game of Sum(经典区间dp)
- flume学习(十):使用Morphline Interceptor
- Light oj 1433 - Minimum Arc Distance【计算几何(坑精度!)】
- flume学习(十一):如何使用Spooling Directory Source
- jzoj 2016.5.21noip模拟赛C 总结
- PJSIP的配置文件和字段
- SQL Server触发器创建、删除、修改、查看示例步骤
- mysql 中插入中文出现的 Incorrect string value: '\xE5\xA5\xBD\xE5\xAE\xB6...' from column错误
- PackageManager使用
- github desktop(for Window)从本地上传项目到github
- Echarts 柱形图 时间横轴的动态生成和数据的动态生成