计算几何-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 ...
随机推荐
- 【Unity|C#】基础篇(15)——异常处理(try/catch/throw)
[学习资料] <C#图解教程>(第22章):https://www.cnblogs.com/moonache/p/7687551.html 电子书下载:https://pan.baidu. ...
- UVA12124 | Assemble (二分)
原题 题目大意:给出你的预算和各类待选硬件来组装计算,同种类的硬件只需且必须选购一种,在保证预算足够的情况下求出最优的合计硬件质量. 根据木桶原理,合计硬件质量 = 所选购硬件中数值最低质量的硬件质量 ...
- Luogu1287 | 盒子与球 (排列组合)
贴一个和其他题解不一样的做法 QWQ 题意:让我们求出 N 个球放入 R 个盒子且每个盒子都必须放球方案数. 首先,对于每一个球,可以将其放入的盒子数量共有 R 个,所以我们可以知道如果无需满足每个盒 ...
- Beego模板 循环和判断几个例子
Beego模板 循环和判断几个例子 Beego的前端几乎是另一种语言.一些循环.判断,不细看文档真的做不出来. 0. Beego的View模板语法规则: beego前端(view)统一使用了 {{ 和 ...
- vjudge A Funny Game 思维题 (其实今天讲的全是数学。。。)
原文链接https://vjudge.net/contest/331993#problem/H Alice and Bob decide to play a funny game. At the be ...
- navicat异常 - 1130-host ... is not allowed to connect to this MySql server
错误描述 用navicat连接数据库报错:1130-host ... is not allowed to connect to this MySql server如何处理 解决方案 1.连接服务器: ...
- XSS挑战之旅,学习笔记
第一关: http://test.ctf8.com/level1.php?name=test 观察到通过get方式传参有会显, 直接打最简单的xss playload: <script>a ...
- Tp5整理
一.命名规则 目录级和文件命名 目录采用小写字母+下划线命名: 类文件名采用驼峰法命名(比如:ArticleDetail.php),其它文件与目录命名规则同: 类名与类文件名须保持一致,采用驼峰法: ...
- Jquery消息提示插件toastr
toastr是一个基于jQuery简单.漂亮的消息提示插件,使用简单.方便,可以根据设置的超时时间自动消失. 1.使用很简单,首选引入toastr的js.css文件 <script src=&q ...
- 线程同步器CountDownLatch
Java程序有的时候在主线程中会创建多个线程去执行任务,然后在主线程执行完毕之前,把所有线程的任务进行汇总,以前可以用线程的join方法,但是这个方法不够灵活,我们可以使用CountDownLatch ...