计算几何-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 ...
随机推荐
- DBeaver下载驱动文件失败
今天首次使用DBeaver软件链接数据库时会进行下载驱动文件,例如如下图所示: 在上图中显示了下载驱动文件失败,提示“无法解决库文件,请检查网络设置”.其实,是可以正常上网的,可能是公司内网的限制,或 ...
- archlinux install.txt
++++++ 注意事项+++ +++++++++++++++++++++++++++ 强烈建议新手移步 Arch Wiki > 新手指南 经验者请参阅 Arch Wiki > 安装指南 若 ...
- vue中jquery详情
jQuery基本语法 $(selector).action() 基本选择器:$("#id") 标签选择器:$("tagName") class选择器:$(&qu ...
- Struts2学习-jsp中超链接传参问题
今天在学习过程中对struts2中超链接的传参问题产生了一些疑惑,不明白jsp中的超链接如何将参数传到Action方法中去的. <s:iterator value="categorys ...
- 2020 Plan
1. English IELTS 7.0 IELTS word 3271, 10 words diff 2 Grammar framework IELTS writing Friends foll ...
- [HNOI2004] L语言 - AC自动机,dp
给定字典和没有标点的文章,求能够被识别的最长前缀. 显然不能贪心,设\(f[i]\)表示前\(i\)个字符构成的前缀能否被识别,然后在AC自动机上暴力转移即可. 具体来说,每走到一个新位置,就沿着fa ...
- C/C++ Windows API——获取系统指定目录(转)
原文地址:C/C++ Windows API——获取系统指定目录 经测试,在win10 VS2017中用wprintf()输出正常,SHGetSpecialFolderPath函数也正常运行 但是用M ...
- STL初学
标准模板库STL初学 线性数据结构 vector 一维向量,相当于数组 list 链表 map 映射,提供(Key,Value)式操作,相当于哈希表 string char字符串 queue 队列,先 ...
- HTML连载63-a标签的伪类选择器
一.a标签的伪类选择器 1.通过观察可以发现a标签存在一定状态 (1)默认状态,从未被访问过 (2)被访问过的状态 (3)鼠标长按的状态 (4)鼠标悬停在a标签上的演示 2.什么是a标签的伪类选择器? ...
- centos7关闭运行的django项目
1.查看django项目的端口对应的PID :sudo netstat -tulpn | grep :8000 2.杀死进程命令:kill -9 pid