poj 1254 Hansel and Grethel 直线求交
来源:互联网 发布:软件批量卸载 编辑:程序博客网 时间:2024/06/10 10:57
题意:
通过点和方向给出两条直线,求他们的交点。
分析:
裸的直线求交,向量做法可避免特殊情况的的讨论。
代码:
//poj 1254//sep9#include <iostream>#include <cmath>using namespace std;const double pi=acos(-1.0);struct P{double x,y;}a,b,c,d;double det(double x1,double y1,double x2,double y2){return x1*y2-x2*y1;}int main(){int cases;scanf("%d",&cases);while(cases--){double alpha;scanf("%lf%lf%lf",&a.x,&a.y,&alpha);alpha=pi*(450-alpha)/180;b.x=a.x+cos(alpha);b.y=a.y+sin(alpha);scanf("%lf%lf%lf",&c.x,&c.y,&alpha);alpha=pi*(450-alpha)/180;d.x=c.x+cos(alpha);d.y=c.y+sin(alpha);double s1=det(c.x-a.x,c.y-a.y,b.x-a.x,b.y-a.y);double s2=det(d.x-a.x,d.y-a.y,b.x-a.x,b.y-a.y);double xx=(s1*d.x-s2*c.x)/(s1-s2);double yy=(s1*d.y-s2*c.y)/(s1-s2);printf("%.4lf %.4lf\n",xx+1e-9,yy+1e-9);}return 0;}
0 0
- poj 1254 Hansel and Grethel 直线求交
- POJ 1254 Hansel and Grethel 笔记
- 1254 Hansel and Grethel
- 1070[Hansel and Grethel]
- zoj 1560 Hansel and Grethel(求两条直线的交点)
- [sicily online]1070. Hansel and Grethel
- 空间直线求交
- poj1254Hansel and Grethel poj1269Intersecting_Lines
- Hansel and Gretel
- poj 1755 Triathlon 半平面交求不等式的 是否为空集-------构造有向直线
- POJ 1755 Triathlon(n^2 半平面交, 两点式和参数式直线求交点)
- POJ 2074 Line of Sight 直线交
- Poj 3304 Segments (直线与线段交)
- POJ 1269 Intersecting Lines 直线交
- poj 3304 判断线段与直线交
- poj 1039 Pipe(直线与线段交+枚举直线)
- poj 1039 Pipe(直线与线段交+枚举直线)
- CodeForces32EHide-and-Seek(线段交,点关于直线对称点)
- Android实现网络多线程断点续传下载
- dev无法调试如何解决
- 生成javadoc帮助文档
- Android第一行代码读书笔记
- 拓扑排序介绍
- poj 1254 Hansel and Grethel 直线求交
- Windows服务器系统入侵简单流程
- string::npos的大小
- lightoj1056Olympics
- git使用笔记
- java用list实现约瑟夫环问题
- 使用py matlib求解函数
- 使用 CAS 在 Tomcat 中实现单点登录
- 10.08JAVA学习