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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. POJ1269(KB13-D 计算几何)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16681   Accepted: 71 ...

  4. 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 ...

  5. hrbustoj 1104:Leyni, LOLI and Line(解析几何,斜截式的应用)

    Leyni, LOLI and Line Time Limit: 1000 MS    Memory Limit: 65536 K Total Submit: 181(54 users)   Tota ...

  6. Intersecting Lines

    Intersecting Lines We all know that a pair of distinct points on a plane defines a line and that a p ...

  7. POJ 1269 - Intersecting Lines - [平面几何模板题]

    题目链接:http://poj.org/problem?id=1269 Time Limit: 1000MS Memory Limit: 10000K Description We all know ...

  8. poj 1269(两条直线交点)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13481   Accepted: 59 ...

  9. 【POJ】1269 Intersecting Lines(计算几何基础)

    http://poj.org/problem?id=1269 我会说这种水题我手推公式+码代码用了1.5h? 还好新的一年里1A了---- #include <cstdio> #inclu ...

随机推荐

  1. burpsuite各个板块儿详细讲解

    burpsuite实战指南,想要的都在这里:https://t0data.gitbooks.io/burpsuite/content/

  2. Hadoop的安装(2)---Hadoop配置

    一:安装JDK hadoop2.x最低jdk版本要求是:jdk1.7(不过推荐用最新的:jdk1.8,因为jdk是兼容旧版本的,而且我们使用的其他软件可能要求的jdk版本较高) 下载地址:https: ...

  3. 2020牛客寒假算法基础集训营1 I-nico和niconiconi

    #include <bits/stdc++.h> #define dbg(x) cout << #x << "=" << x < ...

  4. TCL常用命令

    1.删除文件 file delete A file delete -force A 2.建立文件夹 file mkdir A file mkdir A/A 3.判断文件夹是否存在 file exist ...

  5. 4.Docker 操作容器

    启动容器 所需要的命令主要为 docker run.例如,下面的命令输出一个 “Hello World”,之后终止容器. docker run ubuntu:16.04 /bin/echo 'Hell ...

  6. webpack如何编译ES6打包

    前言:随着ES的普及我们越来越多的开始使用ES6的语法了,当然也随着mvvm框架的流行少不了js模块化,那js模块化又有那些呢 在很早的时候大家都用的命名空间,现在也有人用(库名.类别名.方法名) 后 ...

  7. python3练习100题——030

    这周开始,要重新振作一点吧! 如果每天都想着消费升级,而不是想着如何投入时间精力让自己进步,未来根本就看不到希望. 我想要更认真的活着 live wild 原题链接:http://www.runoob ...

  8. Java 并发核心机制

    目录   一.J.U.C 简介  二.synchronized  三.volatile  四.CAS  五.ThreadLocal  参考资料

  9. 四、CentOS 7安装Oracle JDK

    CentOS 7安装Oracle JDK,查看Linux是否自带的JDK,如有openJDK,则卸载  CentOS7.1 JDK安装 1.卸载自带OPENJDK    用 java -version ...

  10. Java selenium下拉滚动页面

    Selenium强大之处在于,可以操作模拟键盘和点击页面的任何结构,本文对于Selenium的视图滚动操作方法进行解释. 1.可以滑动页面到最底端: //设置本地ChromDrive驱动路径,改成你自 ...