计算几何-Line-Left-Intersect
This article is made by Jason-Cow.
Welcome to reprint.
But please post the article's address.
好好领悟一下vector吧!加一行Left还可以判断是否在直线上...
struct L{
D O;V v;db a;
L(){}
L(D O,V v):O(O),v(v){a=atan2(O.y,O.x);}//atan2(y,x)=atan(y/x) but the x is OK to be zero
bl op<(const L&x)const{return a<x.a;}
};
bl Left(D A,L l){return Cross(l.v,A-l.O)>;}
int main(){
V A(,),B(,);
L l(A,B-A);
printf("l( O(%lf,%lf) V(%lf,%lf) a(%lf))\n",l.O.x,l.O.y,l.v.x,l.v.y,l.a);
printf("( 1, 3) is on the %s\n",Left(V( , ),l)?"Left":"right");
printf("( 3, 1) is on the %s\n",Left(V( , ),l)?"Left":"right");
printf("(-1, 3) is on the %s\n",Left(V(-, ),l)?"Left":"right");
printf("( 0,-2) is on the %s\n",Left(V( ,-),l)?"Left":"right");
printf("( 0, 0) is on the %s\n",Left(V( , ),l)?"Left":"right");
return ;
}
l( O(1.000000,1.000000) V(1.000000,1.000000) a(0.785398)) //a=pi/4
( , ) is on the Left
( , ) is on the right
(-, ) is on the Left
( ,-) is on the right
( , ) is on the right
Intersect(L a,L b)
Return The Dot Of Two Line
D Intersect(L a,L b){
V u=a.O-b.O;
return a.O+a.v*(Cross(b.v,u)/Cross(a.v,b.v));
}
int main()
int main(){
L a(D(,),D(,)-D(-,));
L b(D(,),D(,)-D(,));
D A=Intersect(a,b);
cout<<"("<<A.x<<","<<A.y<<")"<<endl;
return ;
}
(0,1)
计算几何-Line-Left-Intersect的更多相关文章
- POJ P2318 TOYS与POJ P1269 Intersecting Lines——计算几何入门题两道
rt,计算几何入门: TOYS Calculate the number of toys that land in each bin of a partitioned toy box. Mom and ...
- poj1269计算几何直线和直线的关系
We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a p ...
- POJ1269(KB13-D 计算几何)
Intersecting Lines Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16681 Accepted: 71 ...
- poj1269 intersecting lines【计算几何】
We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a p ...
- hrbustoj 1104:Leyni, LOLI and Line(解析几何,斜截式的应用)
Leyni, LOLI and Line Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 181(54 users) Tota ...
- Intersecting Lines
Intersecting Lines We all know that a pair of distinct points on a plane defines a line and that a p ...
- POJ 1269 - Intersecting Lines - [平面几何模板题]
题目链接:http://poj.org/problem?id=1269 Time Limit: 1000MS Memory Limit: 10000K Description We all know ...
- poj 1269(两条直线交点)
Intersecting Lines Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13481 Accepted: 59 ...
- 【POJ】1269 Intersecting Lines(计算几何基础)
http://poj.org/problem?id=1269 我会说这种水题我手推公式+码代码用了1.5h? 还好新的一年里1A了---- #include <cstdio> #inclu ...
随机推荐
- python开发第四篇:函数(1)
函数 阅读目录 一 函数知识体系 二 函数基础 三 函数对象.函数嵌套.名称空间与作用域.装饰器 四 迭代器.生成器.面向过程编程 五 三元表达式.列表推导式.生成器表达式.递归.匿名函数.内置函数 ...
- Luogu4316 | 绿豆蛙的归宿 (期望DP)
题目背景 随着新版百度空间的上线,Blog宠物绿豆蛙完成了它的使命,去寻找它新的归宿. 题目描述 给出一个有向无环图,起点为1终点为N,每条边都有一个长度,并且从起点出发能够到达所有的点,所有的点也都 ...
- 非最大抑制,挑选和目标重叠框 yolo思想原理
非最大抑制,挑选和目标重叠框 yolo思想原理 待办 https://blog.csdn.net/shuzfan/article/details/52711706 根据分类器类别分类概率做排序,(框的 ...
- 《NVM-Express-1_4-2019.06.10-Ratified》学习笔记(5.2)-- Asynchronous Event Request command
5.2 异步事件请求命令 异步事件用于当状态.错误.健康信息这些事件发生时通知主机软件.为了使能这个controller报告的异步事件,主机软件需要提交一个或多个异步事件请求命令到controller ...
- 【转载】JS导出CSV文件
转自:http://www.cnblogs.com/dengnan/p/3990211.html 通过自己实际测试有以下几种方法 方法一通过a标签实现,把要导出的数据用“\n”和“,”拼接成一个字符串 ...
- VSCode C语言编程(一)环境搭建
1.安装Visual Studio Code 2. 安装MinGW编译器 有两种方法 方法(1) 打开https://sourceforge.net/projects/mingw-w64/files/ ...
- c# 让接口实现方法
interface IMy { } static class MyFunc { public static void Func<T>(this T obj) where T : IMy { ...
- 手机内存卡RAW无法格式化的解决办法
突然出现这个问题,这是麻烦: 网上找了各种办法:什么软件修复,disk等修复,创建新磁盘,新扇到,win自动修复啊:开始----运行框中输入 :convert X: /fs:FAT(X为电脑 ...
- testclass面试题
http://www.testclass.net/interview/selenium/ seleniuim面试题 http://www.testclass.net/interview/inter ...
- 《深入理解Java虚拟机》读书笔记六
第七章 虚拟机类加载机制 1.类加载的时机 虚拟机的类加载机制: 虚拟机把描述类的数据从class文件中加载到内存,并对数据进行校验.转换解析和初始化,最终形成了可以被虚拟机直接使用的Java类型,这 ...