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. 在linux中安装nginx

    linux系统安装在vmware中,首先在主机中利用shell工具与虚拟机连接 1.在linux中查看虚拟机的ip地址 在终端输入 ifconfig 红框里面就是ip地址 2.在主机中打开shell工 ...

  2. display: inline-block 布局

    三个元素display: inline-block; 布局 ,其中一个元素中存在其他元素也用了display: inline-block; 无法垂直居中,将这个元素设置为display: inline ...

  3. Leetcode Week2 Two Sum

    Question Given an array of integers, return indices of the two numbers such that they add up to a sp ...

  4. JFinalSwagger插件

    个人博客 地址:http://www.wenhaofan.com/article/20190304101839 jfinal使用swagger的极简插件 码云地址:https://gitee.com/ ...

  5. 认识Flow(一)

    Flow 是 facebook 出品的 JavaScript 静态类型检查工具.Vue.js 的源码利用了 Flow 做了静态类型检查,所以了解 Flow 有助于我们阅读源码. 为什么用 Flow J ...

  6. 理解 nodeJS 中的 buffer,stream

    在Node.js开发中,当遇到 buffer,stream,和二进制数据处理时,你是否像我一样,总是感到困惑?这种感觉是否会让你认为不了解它们,以为它们不适合你,认为而这些是Node.js作者们的事情 ...

  7. HDU1241 Oil Deposits(dfs+连通块问题)

    背景描述 ztw同志负责探测地下石油储藏.ztw现在在一块矩形区域探测石油.他通过专业设备,来分析每个小块中是否蕴藏石油.如果这些蕴藏石油的小方格相邻(横向相邻,纵向相邻,还有对角相邻),那么它们被认 ...

  8. Controller 和 Action -1

    https://www.cnblogs.com/willick/p/3331521.html MVC 的每个请求都会提交到 Controller 处理.Controller 包含了对请求的逻辑处理,能 ...

  9. element模态框dialog中的select组件中选中无反应无显示

    https://blog.csdn.net/PGguoqi/article/details/90240650 在vue里,当你对一个不存在的属性或对象直接“.”进行赋值,或者对数组不存在的索引项直接用 ...

  10. 边捆绑: Content Importance Based Edge Bundling for Graph Visualization

    Problem 当图所要表达的信息较多时, 图中可能会充满交叉的线[1-2], 甚至整个显示空间都被点.线所覆盖, 这时想通过观察来获取图中的重要信息将会变得非常困难, 这种现象称为图的视觉混乱. K ...