题意:
    判断直线间位置关系: 相交,平行,重合

 include <iostream>
#include <cstdio>
using namespace std;
struct Point
{
int x , y;
Point(int a = , int b = ) :x(a), y(b) {}
};
struct Line
{
Point s, e;
int a, b, c;//a>=0
Line() {}
Line(Point s1,Point e1) : s(s1), e(e1) {}
void Coefficient()//get a,b,c
{
a = e.y - s.y;
b = s.x - e.x;
c = e.x * s.y - s.x * e.y;
if(a < ) a = -a,b = -b,c = -c;
}
};
int Line_Inter_Line(Line & l1,Line & l2, double &x,double &y)//直线 平行: 0, 相交:1, 重合: 2
{
l1.Coefficient();
l2.Coefficient();
if(l1.a * l2.b == l2.a * l1.b)
{
if(l1.b * l2.c != l1.c * l2.b || l1.a * l2.c != l1.c * l2.a) return ;
else return ;
}
x =(double) - (l1.c * l2.b - l2.c * l1.b) / (l1.a * l2.b - l2.a * l1.b);// (c1b2-c2b1)/(a1b2-a2b1)
y =(double) (l1.c * l2.a - l2.c * l1.a) / (l1.a * l2.b - l2.a * l1.b);// (c1a2-c2a1)/(a1b2-a2b1)
return ;
}
int n;
int main()
{
puts("INTERSECTING LINES OUTPUT");
scanf("%d", &n);
while (n--)
{
Point p1, p2, p3, p4;
double x, y;
scanf("%d%d%d%d%d%d%d%d",&p1.x, &p1.y, &p2.x, &p2.y, &p3.x, &p3.y, &p4.x, &p4.y);
Line l1 = Line(p1, p2), l2 = Line(p3, p4);
int f = Line_Inter_Line(l1, l2, x, y);
if (f == ) puts("NONE");
else if (f == ) puts("LINE");
else printf("POINT %.2f %.2f\n", x, y);
}
puts("END OF OUTPUT");
}

POJ 1269 - Intersecting Lines 直线与直线相交的更多相关文章

  1. POJ 1269 Intersecting Lines【判断直线相交】

    题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0) ...

  2. poj 1269 Intersecting Lines——叉积求直线交点坐标

    题目:http://poj.org/problem?id=1269 相关知识: 叉积求面积:https://www.cnblogs.com/xiexinxinlove/p/3708147.html什么 ...

  3. POJ 1269 Intersecting Lines(判断两直线位置关系)

    题目传送门:POJ 1269 Intersecting Lines Description We all know that a pair of distinct points on a plane ...

  4. POJ 1269 Intersecting Lines(直线相交判断,求交点)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8342   Accepted: 378 ...

  5. poj 1269 Intersecting Lines(直线相交)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8637   Accepted: 391 ...

  6. 判断两条直线的位置关系 POJ 1269 Intersecting Lines

    两条直线可能有三种关系:1.共线     2.平行(不包括共线)    3.相交. 那给定两条直线怎么判断他们的位置关系呢.还是用到向量的叉积 例题:POJ 1269 题意:这道题是给定四个点p1, ...

  7. POJ 1269 Intersecting Lines (判断直线位置关系)

    题目链接:POJ 1269 Problem Description We all know that a pair of distinct points on a plane defines a li ...

  8. 简单几何(直线位置) POJ 1269 Intersecting Lines

    题目传送门 题意:判断两条直线的位置关系,共线或平行或相交 分析:先判断平行还是共线,最后就是相交.平行用叉积判断向量,共线的话也用叉积判断点,相交求交点 /********************* ...

  9. POJ 1269 Intersecting Lines(直线求交点)

    Description We all know that a pair of distinct points on a plane defines a line and that a pair of ...

随机推荐

  1. hdu 3460

    算法:字典树 题意:给你一些单词,有一台打印机只能进行以下三种操作 1.读入 2.删除 3.打印 让你输出最少的操作次数将这些单词全部打印出来: (字典树节点-1)*2  表示读入和删除操作: 打印操 ...

  2. 织梦dedecms返回上一级链接代码

    如题:织梦dede手机页面,如果我进入了下一级页面,想回上一级,<a href="xx">该用什么标签? 用JS实现,代码如下 <a href="jav ...

  3. git merge –squash介绍

    Git相对于CVS和SVN的一大好处就是merge非常方便,只要指出branch的名字就好了,如: $ git merge another $ git checkout another # modif ...

  4. 动态编译添加php模块

    注意:转载请注明出处:http://www.programfish.com/blog/?p=85 在很多时候我们用linux里搭建web服务器的时候会需要编译安装php套件,而在编译安装后可能又会需要 ...

  5. django删除migrations

    先把migrations文件夹里面的数据删除. 删除数据库中关联的表 删除django_migrations里面关联的数据(因为在migrate的时候发现django_migrations表有相关数据 ...

  6. 字典:当索引不好用时2 - 零基础入门学习Python026

    字典:当索引不好用时2 让编程改变世界 Change the world by program 上节课我们学习到在一些情况下,比序列更实用的映射类型:字典.我们知道字典也有个关键符号就是大括号(也叫花 ...

  7. 64位Ubuntu14.04搭建ADT开发环境

    本来放假是要出去玩的,结果出游计划拖到了周一,今天先来无事看看ubuntu最近发展得怎么样了,顺便把ADT也搭建好,方便以后研究android框架.想想在windows下,ADT直接down下来解压就 ...

  8. 异步编程设计模式Demo - AsyncComponentSample

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...

  9. Java中的日期处理类

    在Java中可以使用Date类和Calendar类来处理日期 但是Date类很多方法都过时了,推荐使用Canlendar类来处理日期,并对日期的格式化做了介绍.下面的部分将会逐一介绍 Date类 Ja ...

  10. 163k地方门户网站系统js小Bug

    163k地方门户网站系统后台在Firefox下无法通过选择区域来获取相对应的地段,IE浏览器下无些问题. Firebug提示错误为: ReferenceError: requestdataquyu i ...