题目描述:
http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=111302&format=html
另外做该题的时候参考了ybfq_wanglang的解题思路,地址如下:
http://hi.baidu.com/ybfq_wanglang/blog/item/9fff3b0d116176206159f33d.html
http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=111302&format=html
另外做该题的时候参考了ybfq_wanglang的解题思路,地址如下:
http://hi.baidu.com/ybfq_wanglang/blog/item/9fff3b0d116176206159f33d.html
//该题关键在于判断线段是否与圆相交 //具体解释参见代码注释 //还有就是该题不用求切点坐标 //利用弧度完成圆弧段的长度计算 //用到反余弦函数 #include <cstdio> #include <cmath> #define eps 1e-8 struct point { double x, y; }; struct line { point a, b; }; //叉积 double xmult(point p1, point p2, point p0) { return (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.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)); } //计算点到直线距离 double disptoline(point p, point l1, point l2) { return fabs(xmult(p, l1, l2)) / distance(l1, l2); } //判断线段(端点都在圆外)和圆相交,不包括端点和相切 int intersect_seg_circle(point c, double r, point l1, point l2) { point t = c; t.x += l1.y - l2.y; t.y += l2.x - l1.x; //点t点c构成l1 l2 的垂线,如果l1 l2 在直线t c异侧 , //且圆心到l1 l2 的距离小于 r,则l1 l2 与圆相交 return xmult(l1, c, t) * xmult(l2, c, t) < eps && disptoline(c, l1, l2) < r; } int main() { point p1, p2, origin; //origin为圆心 origin.x = origin.y = 0.0; double r; int ncase; scanf("%d", &ncase); while(ncase--) { scanf("%lf %lf %lf %lf %lf", &p1.x, &p1.y, &p2.x, &p2.y, &r); double d1 = distance(p1, p2); //点p1 p2间的距离 if(!intersect_seg_circle(origin, r, p1, p2)) //如果线段与圆不想交 printf("%.3lf\n", d1); else { double d2 = distance(origin, p1); double d3 = distance(origin, p2); double d = sqrt(d2 * d2 - r * r); d += sqrt(d3 * d3 - r * r); double t = acos((d2 * d2 + d3 * d3 - d1 * d1) / (2 * d2 * d3)); t -= acos(r / d2) + acos(r / d3); //现在t为圆上的绳子对应的圆心角的弧度 d += t * r; printf("%.3lf\n", d); } } return 0; }
发表评论
-
ACM 之 Java BigInteger
2011-06-01 20:26 0Java 的大整数类在ACM 中大有用武之地 ... -
判断点是否构成多边形, 顶点连续给出
2011-05-26 14:27 0#include <cstdio> #inc ... -
poj pku 1981 Circle and Points 点与圆 位置关系
2011-05-26 11:29 1264题目描述: http://poj.org/problem?id ... -
poj 1032 Parliament 数学
2011-05-25 17:34 1215题目描述: http://poj.org/problem?i ... -
poj 1385 Lifting the Stone 多边形重心
2011-05-25 11:13 1036题目描述: http://poj.org/problem?i ... -
poj 2676 Sudoku dfs 深搜
2011-05-16 21:05 875题目描述: http://poj.org/problem?i ... -
hdoj 2064 汉诺塔III 递推
2011-05-15 22:29 887题目描述: http://acm.hdu.edu.cn/sh ... -
hdoj 1207 汉诺塔II dp 动态规划
2011-05-15 21:22 1669题目描述: http://acm.hdu.edu.cn/sh ... -
poj 2506 Tiling 递推
2011-05-15 11:18 912题目描述: http://poj.org/problem?i ... -
poj 2420 A Star not a Tree? 多边形 费马点
2011-05-14 18:57 1800题目描述: http://poj.org/problem?i ... -
poj 2954 Triangle Pick 定理
2011-05-14 16:36 1086题目描述: http://poj.org/problem?i ... -
poj 1012 Joseph
2011-05-10 17:42 1236题目描述:poj.org/problem?id=10 ... -
zoj 1081 Points Within 点与多边形关系
2011-05-07 17:51 1135题目描述: http://acm.zju.edu.cn/on ... -
poj 1835 宇航员
2011-05-03 17:00 808题目描述:http://poj.org/problem?id ... -
poj 2398 Toy Storage
2011-04-23 20:19 718题目描述:http://www.poj.org/proble ... -
poj 1654 Area 多边形面积
2011-04-23 20:10 901题目描述:http://poj.org/proble ... -
poj 2318 TOYS 点 直线 位置关系
2011-04-23 10:06 670题目描述:http://poj.org/problem?id= ... -
poj pku 1673 EXOCENTER OF A TRIANGLE 三角形 垂心
2011-04-09 16:41 548题目描述:http://poj.org/problem?id= ... -
pc 111303 uva 10195 The Knights Of The Round Table
2011-04-04 16:06 756题目描述:http://www.programming-cha ... -
poj 1971 Parallelogram Counting 平行四边形个数
2011-04-03 10:05 1218题目描述:http://poj.org/problem?id= ...
相关推荐
Enough Rope to Shoot Yourself in the Foot Rules for C and C Programming
Physics and parameters can be tweaked in play mode for real time feedback, and the state can optionally be saved back to edit mode. This eliminates turnaround time and increases productivity. Check ...
unity用于制作绳索的插件Rope unity用于制作绳索的插件Rope unity用于制作绳索的插件Rope unity用于制作绳索的插件Rope
With Obi Rope you can create ropes in a matter of seconds, with complete control over their shape and behavior. The ropes can collide with the environment and with each other, and can be attached to ...
Rope
unity绳子插件 Obi Rope 6.0
Rope3D数据集可视化,与kitti可视化不同,需要denorm相机内参文件
Obi Rope 3.3.1 exported
Unity绳子解决方案、基于粒子的高级物理引擎,可模拟各种可变形材料的行为。 但仅限于 Windows、Mac、Linux、iOS 和 Android 平台。 功能: - 使用样条线进行非线性、非破坏性的绳索编辑。在编辑绳索时,实时获得...
圈码字体圈码字体
字体,圈码类。适用于加圈脚注各用书稿论文文档排版。
With Obi Rope you can create ropes in a matter of seconds, with complete control over their shape and behavior. The ropes can collide with the environment and with each other, and can be attached to ...
QuickRopes Rope Physics v2.1 unity3d的绳索运动轨迹
TESTING SPECIFICATION FOR ROPE MANUFACTURER IMPLEMENTATION
Ultimate Rope Editor是一种功能强大的工具,它可以生成过程性的Rope,并将Rope物理应用到已有的网格中。 物理和参数可以在播放模式下进行实时反馈,并且可以选择将状态保存回编辑模式。这消除了周转时间,提高了...
unity绳索系统插件Obi Rope 4.0.2 所支持的Unity版本:2018.1.0 及以上版本 使用Obi Rope,您可以在几秒钟内创建绳索,完全控制其形状和行为。绳索可以与环境相互碰撞,并且可以附着在刚体上。 4.0中的新功能:...
Rope+BETA+4.0+链子+绳子脚本示例
使用 Obi Rope,你可以在几秒内创建绳索和杆子,同时完全控制它们的形状和行为:导向粒子技术可以对杆子使用不同的扭转/扭曲特效。绳索更加轻量化,并且能裁剪/调整尺寸。两者都可以与环境发生碰撞以及相互碰撞,也...